Home > Net >  Remove some element in iframe with jquery
Remove some element in iframe with jquery

Time:04-29

In the code below, with jquery, I'd like remove element (and the child 'li') and after that add some code to the

Could you tell me how do this ?

<iframe id="myIframe">
    #document
    <html>
        <head>
        </head>
        <body>
            <div  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 Delete(iframeName) {

    $('#'   iframeName)  

}

Thanks,

CodePudding user response:

$("#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.

  • Related