<div id="grandfather">
<div id="uncle"></div>
<div id="father>
<div id="me"></div>
</div>
</div>
我在 $("#me") ,我想选择我的叔叔,使用如下内容:
$("#me").find("#uncle")
$("#me").next("#uncle")
$("#me").prev("#uncle")
How ?
你可以使用$.parent
and $.prev
假设你的叔叔总是高于你的父亲:
$(this).parent().prev(); // where 'this' is #me
你也可以一直走到你的祖父那里,从那里找到叔叔:
$(this).parents("#grandfather").find(".uncles");
或者你可以搜索你父亲的兄弟姐妹:
$(this).parent().siblings("#uncle");
我鼓励您阅读穿越用于各种其他方法的 jQuery API 的一部分。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)