0

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 2

2

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 } 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Working like a charm! :-)
1
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

Thanks for reply :) The other solution is the same, but looks a little more elegant.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.