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.
For More Information Please Refer:
You May Also Like to Read: