Search This Blog

Wednesday, August 25, 2010

How to access iFrame elements using jQuery?

To access the iFrame elements inside the javascript, there is a method contents(), which enables us to access elements of iFrame.

See the example below :

$(function(){
    var iFrameDOM = $("iframe#ID").contents();
    //Now you can use find() to access any element in the iframe:

    iFrameDOM.find(".message").slideUp();
    //Slides up all elements classed 'message' in the iframe
});

No comments:

Post a Comment