admin管理员组文章数量:1190563
How to select a node after $(this)
that matches a certain selector?
eg:
<textarea id="foo"></textarea>
<a href="#">someLink</a>
<a href="#">someOtherLink</a>
<textarea id="bar"></textarea>
With out directly selecting #bar via $("#bar"), how can i select it from within #foo?
How to select a node after $(this)
that matches a certain selector?
eg:
<textarea id="foo"></textarea>
<a href="#">someLink</a>
<a href="#">someOtherLink</a>
<textarea id="bar"></textarea>
With out directly selecting #bar via $("#bar"), how can i select it from within #foo?
Share Improve this question asked Dec 10, 2010 at 6:25 BabikerBabiker 18.8k28 gold badges82 silver badges127 bronze badges 2- What's the rule/selector you're trying to match on? textarea? – Paul Schreiber Commented Dec 10, 2010 at 6:27
- @Paul Schreiber: The first next textarea. – Babiker Commented Dec 10, 2010 at 6:30
2 Answers
Reset to default 25Use the nextAll() method:
$("#foo").nextAll("textarea").first();
Or:
$("#foo").nextAll("textarea:first");
Or even:
$("#foo").nextAll("textarea:eq(0)");
Check out siblings()
$('#foo').siblings('textarea:first').addClass('found');
jsbin demo here
本文标签:
版权声明:本文标题:javascript - Using jQuery how to select the first next element(s) that matches a certain selector? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738431580a2086432.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论