简体   繁体   English

用 jquery 删除 iframe 中的一些元素

[英]Remove some element in iframe with jquery

In the code below, with jquery, I'd like remove element (and the child 'li') and after that add some code to the在下面的代码中,对于 jquery,我想删除元素(和子“li”),然后添加一些代码到

Could you tell me how do this?你能告诉我怎么做吗?

<iframe id="myIframe">
    #document
    <html>
        <head>
        </head>
        <body>
            <div class="spinner" style="display:none;"></div>
            <ul>
                <li>
                    <p contenteditable="false">11111</p>
                </li>
                <li>
                    <p contenteditable="true"></p>
                </li>
            </ul>
        </body>
    </html>
</iframe>

I have a function for this:为此,我有一个 function:

function Delete(iframeName) {

    $('#' + iframeName)  

}

Thanks,谢谢,

$("#myIframe").contents().find("#mydiv").remove();

However , this assumes the browser is not blocking access to the iframe. If the iframe is hosted on another domain and has cross-domain security measures enabled it will not allow you to change the content in the iframe.但是,这假设浏览器未阻止对 iframe 的访问。如果 iframe 托管在另一个域上并且启用了跨域安全措施,则不允许您更改 iframe 中的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM