I have a bunch of text inputs with numeric values:
<input type='text' value='25' />
<input type='text' value='0' />
<input type='text' value='45' />
<input type='text' value='-2' />
.
. etc...
I need to select only those inputs with values greater than 0. How can I do that using jQuery?
Something like this, using .filter()
:
$('input[type="text"]').filter(function() {
return parseInt($(this).val(), 10) > 0;
});
//select all text type inputs
$('input[type=text]').each(function(){
var val = parseInt($(this).val());
if(val > 0)
//your logic here
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With