注册 登录
编程论坛 jQuery论坛

在父页面内嵌了两个ifream 现在在其中一个子页面需要向父页面添加节点,该怎么实现 求大神指点

qzx10010 发布于 2018-09-08 15:11, 2658 次点击
<div class="container">
            
            <iframe id="iframeleft" frameborder="0" src="allwork-left.html" scrolling="no">
               
            </iframe>
            <iframe id="iframeright" frameborder="0" src="allwork-right.html" scrolling="no"></iframe>
        </div>
2 回复
#2
icecool2018-12-11 09:09
子页:1.htm
程序代码:
<html>
<head>
<title>test</title>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){

                      $("button").click(function(){
                                  var htx=$(".ul1").html();
                                  $(".ul2").append(htx);
                                  $(window.parent.document.body).append(htx);
                       });
});
</script>
</head>
<body>
<ul class="ul1" id="ul1">
        <li>1.aaaaaaaaaaaaaaaa</li>
        <li>2.bbbbbbbbbbbbb</li>
        <li>3.cccccccccccccccc</li>
</ul>
<button>插入</button>
<ul class="ul2">
</ul>
</body>
</html>


父页:
程序代码:
<html>
<head>
<title>test</title>
<scritp>
</script>
</head>
<body>
<iframe style="width:250px;height:200px;" id="iframeleft" frameborder="0" src="1.htm" />
<ul id="ul3" class="ul3">
</ul>
</body>


要放到服务器上运行

1