javascript - How to have "and" and "or" conditions in jQuery selector -
i check if 2 separate divs returning true hasclass.
if($('#first-name, #last-name').hasclass('has-focused')) { $('#personal-info').valid(); }
this checks if either 1 has class 'has-focused'.
instead this:
if($('#first-name').hasclass('has-focused')&&$('#last-name').hasclass('has-focused')) { $('#personal-info').valid(); }
however, solution feels bit clumsy. possible this.
if($('#first-name'&&'#last-name').hasclass('has-focused')) { $('#personal-info').valid(); }
you can't that, though can have filter based solution like
if ($('#first-name, #last-name').not('.has-focused').length == 0) { $('#personal-info').valid(); }
Comments
Post a Comment