Reputation: 119
Is there a way to easily write a condition that result in true whenever one of the selected jQuery element satisfy a certain condition?
if($('input[name*="box_feature"]').attr('value') === undefined)) {
}
I have the above code, but the problem is that sometime we have more than one input with the same name and one of them can be defined. So what's the easiest way to do this in jQuery, that is, checking if at least one of the selected element meet a certain condition.
Upvotes: 0
Views: 198
Reputation: 12025
You can check multiple attributes in the selector:
if( $('input[name*="box_feature"][value]').length > 0 ) {
alert('found');
}
References:
Upvotes: 2