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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -