I've got couple of "select" elements, I need a true/false selector, whether one or any of them has a selected option with other than default which is "0" value. Any ideas?
2 Answers
Why not to use filter?
$("select").filter(function(index) { return $(this).val() != "0"; }) if you wish to use it in condition
if($("select").filter(function(index) { return $(this).val() != "0"; }).size() > 0) { //Do something } 1 Comment
Anonymous
Thanks! Working like a charm! :-)
var is_all_zero = true; $('select').each(function() { if ($(this).val() !== '0') { is_all_zero = false; return false; } }); And replace the selector with yours.
1 Comment
Anonymous
Thanks for reply :) The other solution is the same, but looks a little more elegant.