简体   繁体   English

所有未选择的选项标签

[英]All option tags that aren't selected

I need to select all <option> tags ( .just_added select option ) that aren't selected with jQuery. 我需要选择所有未使用jQuery选择的<option>标签( .just_added select option )。

This is what I got so far... 这就是我到目前为止所得到的...

$('.just_added select option:selected');

The problem is that it selects all <option> tags that are selected, but I need to select all <option> tags that aren't selected. 问题在于它会选择所有选择的<option>标签,但是我需要选择所有未选择的<option>标签。

Any ideas? 有任何想法吗? Thanks in advice! 感谢您的建议!

You can use :not [docs] : 您可以使用:not [docs]

$('.just_added select option:not(:selected)');

Or without jQuery pseudo selectors (using the .not() [docs] method): 或没有jQuery伪选择器(使用.not() [docs]方法):

 $('.just_added select option').not(function() {
     return this.selected;
 });
$('.just_added select option:not(:selected)');

非选择器应该正是您想要的:

$('.just_added select option:not(:checked)');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM