1.html
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function th() {
window.open("2.html", "退货", "with=700px,height=530px,top=0");
}
</script>
<div id="div1"></div>
<input type="button" value="click me" onclick="th()" />2.html<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#fz").click(function() {
var $aa=$("#di").clone(true);//.appendTo($("#di2"));
alert($aa);
$(window.opener.document.body).children("#div1").append($aa);
});
});</script>
<div id="di">asdfadsfa</div>
<input id="fz" type="button" value="clone" onclick="cl()" />我主要想将open的页面所克隆的东西父级能够接收并显示出来。但是似乎
$(window.opener.document.body).children("#div1").append("dfasdfa");就可以,
以上这句$(window.opener.document.body).children("#div1").append($aa); 就不行了。
要是有其他方法,不妨告诉小弟。谢谢。
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function th() {
window.open("2.html", "退货", "with=700px,height=530px,top=0");
}
</script>
<div id="div1"></div>
<input type="button" value="click me" onclick="th()" />2.html<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#fz").click(function() {
var $aa=$("#di").clone(true);//.appendTo($("#di2"));
alert($aa);
$(window.opener.document.body).children("#div1").append($aa);
});
});</script>
<div id="di">asdfadsfa</div>
<input id="fz" type="button" value="clone" onclick="cl()" />我主要想将open的页面所克隆的东西父级能够接收并显示出来。但是似乎
$(window.opener.document.body).children("#div1").append("dfasdfa");就可以,
以上这句$(window.opener.document.body).children("#div1").append($aa); 就不行了。
要是有其他方法,不妨告诉小弟。谢谢。
解决方案 »
- 写了javascript弹出“为了有利于保护安全性,Internet 已限制网页运行可以访问计算
- 初学者JQUERY 局刷DIV的疑问
- JQure 入门 帮忙看看
- JS随机取数值并赋值
- 一直都没有什么好的方法解决的问题!!请赐教
- <td onselectstart="javascript:selection.empty();"><input type="text" /></td>怎么使input的选择保持有效?
- 关于BUTTON的这种问题应该如何设置???
- 如何替换<>里面内容的指定字符串.
- 如何用javascript改变表格背景图片
- Bootstrap 弹出框怎么设置为可拖动?
- jquery克隆的数据能否使用
- JS 正则表达式提取数字和字符
$(window.opener.document.body).children("#div1").append($("#di").html());
<input id="fz" type="button" value="clone" onclick="cl()" />
改为
<input id="fz" type="button" value="clone"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function th() {
window.open("2.html", "退货", "with=700px,height=530px,top=0");
}
</script>
<form><div id="div1"></div>
<input type="button" value="click me" onclick="th()" /></form>
2.html
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#fz").click(function() {
$(window.opener.document.body).children("#div1").append($("#di").html());
});
});</script>
<div id="di"> <table id="myTable2" width="100%" cellpadding="0" cellspacing="0" border="1" bordercolor="#aca899" style="border-collapse:collapse" align=center> <tr>
<td height="19px" style="background:#ebebeb">序号</td>
<td height="19px" style="background:#ebebeb">商品条码</td>
<td height="19px" style="background:#ebebeb">商品名称</td>
<td height="19px" style="background:#ebebeb">单位</td>
<td height="19px" style="background:#ebebeb">规格</td>
<td height="19px" style="background:#ebebeb">生产厂商</td>
<td height="19px" style="background:#ebebeb">单价</td>
<td height="19px" style="background:#ebebeb">数量</td>
<td height="19px" style="background:#ebebeb">批准文号</td> </tr>
</table> </div>
<input id="fz" type="button" value="clone" />就这么写,1.html里添加多了一个form后就失效了。
<script>
function th() {
window.open("2.html", "退货", "with=700px,height=530px,top=0");
}
</script><div id="div1"></div>
<form>
<input type="button" value="click me" onclick="th()" /></form>
将div1移至form外面就可以了。。
改成
$(window.opener.document.body).find("#div1").append($("#di").html());试试
问题是为啥加了form后用children就不行了呢
因为children()只查找指定对象的子元素而不是查找其所有后代元素 不是很明白。能否简单再说明下呢?
<script>
$(function(){
$('#me').children().each(function(){
alert($(this).attr("id"))
})
})
</script>
<div id="me">
<form id="f1">
<div id="d1"></div>
</form>
<div id="d2"></div>
</div>对me来说,它的一级子节点就是id=f1的form和id=d2的div。id=d1的div是不包含在内的。它属于后代元素了