$(document).ready(function () {
$("#bcscan").submit(function (e) {
e.preventDefault();
if($("select").val() === '#') {
$(this).addClass("warning");
}
else {
ajaxPost();
}
});
});
I’m using following function, how can I modify it to add class warning, if one of select element’s value = “#”?
Currently it’s adding warning class to all selects
I think this may be what you want:
That selects all
selectelements, filters it down to those elements whose current value is equal to#, then adds thewarningclass to that subset.I’ll leave my original answer here, though given the changes to the question it’s likely no longer relevant. This is my last stab at guessing what it is you want – if this is useful to you, great; if not, oh well.
That checks all
selectelements when the form is submitted – if any of them have a value of#it adds thewarningclass to that select element. If none of them have a value of#it goes ahead and calls the ajaxPost() function.