How do you get a ?
Above answers gave good solutions using Javscript. Here is a simple jQuery solution:
$('#iframeId').contents().find('div')
The trick here is jQuery's .contents()
method, unlike .children()
which can only get HTML elements, .contents()
can get both text nodes and HTML elements. That's why one can get document contents of an iframe by using it.
Further reading about jQuery .contents()
: .contents()
Note that the iframe and page have to be on the same domain.