Is there a way to manipulate the HTML of an iframe that is from the same domain using jQuery?
Thanks for the help.
HTML's DOM, or Document Object Model, lets you replace an iframe's HTML code by giving JavaScript's getElementById function access the "src" attribute. Each iframe must be labeled with a unique ID selector.
However, it's also possible to use a really simple jQuery to access the elements within the iFrame. Check it out below: $(document). ready(function(){ var iFrameDOM = $("iframe#frameID").
# jQuery Code to Get HTML Content of IFrame$("#myButton"). on('click', function() { alert($("#myIframe"). contents(). find("html").
When you can communicate with the code inside an iFrame, you can make any change you want to the code within that iFrame.
You'll have to parse the iframe content.
$("#frameid").contents().find("div").html('My html');
More here : http://api.jquery.com/contents/
You can use contents()
to manipulate the contents of the iframe
.
$("#frameDemo").contents().find("div").html("new HTML content goes here");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With