I have included JQuery on my main page which is a html page, in the main page there is an iFrame and in the iFrame I am calling another HTML page. I want to use jquery in the html page which is being called in the iFrame, is it possible to use the JQuery which is included in the main page? if it is then please let me know how?
Share
Are the pages in the same domain? (Same origin policy.)
If so then from the iframe do
parent.$(xxx)but be aware the jquery will be manipulating the top level document! Not the iframe!If you want to manipulate the iframe do
$(xxxx, $('iframe').contents())– i.e. you set the context to the iframe, then use jQuery like usual. You would probably want to set$('iframe').contents()to a variable – and if you have more than one iframe give them an ID so jquery can find the right one.