Wednesday, August 4, 2010

How to access contents of an iFrame from JQuery

Suppose you have an iFrame


<iframe id="iframeID" ...></iframe>


Your iFrame contains div with id=”myDiv”:



<div id="myDiv">DIV contents here</div>


You can retrieve contents of a div using the following line of code:




$('#iframeID').contents().find('#myDiv').html();

No comments:

Post a Comment