jQuery选择为选择选项
答
为什么不使用filter
?
$("select").filter(function(index) {
return $(this).val() != "0";
})
,如果你想使用它的条件
if($("select").filter(function(index) {
return $(this).val() != "0";
}).size() > 0) {
//Do something
}
答
var is_all_zero = true;
$('select').each(function() {
if ($(this).val() !== '0') {
is_all_zero = false;
return false;
}
});
并用你的替换选择器。
+1
感谢您的答复:)另一种方案是一样的,但看起来多了几分优雅。 – Anonymous 2012-03-10 15:26:20
谢谢!像魅力一样工作! :-) – Anonymous 2012-03-10 15:24:38