javascript - Multi-Conditional Selectors in jQuery - Stack Overflow

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

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745477258a4629400.html

相关推荐

  • javascript - Multi-Conditional Selectors in jQuery - Stack Overflow

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

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信