基本上我需要抓取父元素的第一個孩子,通常但不限於。Jquery的eq(0),「.. first-child」,第一個()如果它的iframe沒有抓第一個孩子
<div>
<iframe src="www.asource.com">GRAB THIS AFTER A BUTTON IS CLICKED</iframe>
</div>
我曾嘗試以下
$("#parent").eq(0).prop("tagName");
$("#parent").first().prop("tagName");
$("#parent:first").prop("tagName");
$("#parent:nth-child(1)").prop("tagName");
$("#parent:lt(1)").prop("tagName");
所有這些返回一個「格」時,我提醒他們。我得到道具名稱的原因是因爲我想使用find()來獲取元素。
$("parent").find(ONE OF THE PROP CALLS ABOVE).animate({.....
,因爲當我這樣做:
$("parent").find('**iframe**').animate({.....
那就是我可以抓住並正確的動畫效果的IFRAME的唯一方案。但是由於我們不知道第一個孩子是否是iframe,我使用.prop()來獲取第一個元素標籤名並找到它。 (請注意,我嘗試使用.animate直接使用.animate(...)而不是.prop(...)但是也沒有獲取iframe。 真的很感謝一些指導
什麼是「#parent」我看不出有什麼元素與ID父級 – epascarello