Jquery's eq(0), "..first-child", first() not grabbing first child if its
an iframe
Basically I need to grab the first child of a parent element, usually but
not limited to an <iframe>.
<div>
<iframe src="www.asource.com">GRAB THIS AFTER A BUTTON IS
CLICKED</iframe>
</div>
I have tried the following
$("#parent").eq(0).prop("tagName");
$("#parent").first().prop("tagName");
$("#parent:first").prop("tagName");
$("#parent:nth-child(1)").prop("tagName");
$("#parent:lt(1)").prop("tagName");
All of these return a "div" when I alert them. The reason I am getting the
prop name was because I wanted to use the find() to get the element.
$("parent").find(ONE OF THE PROP CALLS ABOVE).animate({.....
because when I do:
$("parent").find('**iframe**').animate({.....
that is the only scenario that I can grab and properly animate an iframe.
however since we don't know if the first child is an iframe or not, i used
.prop() to get the first element tag name and find it. (please note, i
tried all the above attempts directly with .animate(...) instead of
.prop(...) but that also didn't grab the iframe. Would really appreciate
some guidance
No comments:
Post a Comment