最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Multi-Conditional Selectors in jQuery - Stack Overflow

programmeradmin0浏览0评论

I'm trying to select elements with multiple conditions, for example I'm doing the following at the moment:

$('#myspan').find('input:visible').each(myfunc);

Although I know you can do things like $('#myspan input:visible') but it didn't work for me. I need to check for inputs within the span #myspan which are visible and are checked. Any ideas?

I'm trying to select elements with multiple conditions, for example I'm doing the following at the moment:

$('#myspan').find('input:visible').each(myfunc);

Although I know you can do things like $('#myspan input:visible') but it didn't work for me. I need to check for inputs within the span #myspan which are visible and are checked. Any ideas?

Share Improve this question edited Mar 25, 2009 at 21:48 cletus 626k169 gold badges919 silver badges945 bronze badges asked Mar 25, 2009 at 10:32 Kieran SeniorKieran Senior 18.2k27 gold badges96 silver badges140 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

Try:

$("#myspan :checked:visible").each(function() {
    // do stuff
});
$('input:visible', '#myspan').find(':checked').each(function() {
    alert(this.id);
});

Should do the trick. I like seperating things because I like to think it helps jQuery parse better.

发布评论

评论列表(0)

  1. 暂无评论