Is there anyway to access an iframe's contents via a selector? Something like this:
$("iframe::contents .my-foo")
I'm constantly accessing an iframe's contents for a project I'm currently working on and $("iframe").contents().find(".my-foo")
is becoming a bit tedious to type out.
If this feature doesn't exist in jquery out of the box, is there a plugin that provides this functionality? If not how could I write such a plugin?
contents()
=children()
+plaintext
. Some may be thinking what is the use ofcontents()
when we could just use$('iframe').find('.my-foo')
, then please readThe contents() method can also access the HTML of an iframe, if it is in the same domain.
from w3schools.com/jquery/traversing_contents.asp – Nierman