javascript - return true if two elements having same class using operators in jquery -



javascript - return true if two elements having same class using operators in jquery -

i have 2 elements ids #online , #offline, want check whether both these elements having specific class .selectedusing , operator in selector. like,

$("[id='online']&&[id='offline']").hasclass('selected');

if both these elements having selected class, should homecoming true else false;

is possible in jquery?

i know can done this,

($("[id='offline']").hasclass('selected') && $("[id='online']").hasclass('selected'))

but looking simplified implementation of same.

try using .filter() along multiple selector accomplish need,

$('#online,#offline').filter('.selected').length == 2

javascript jquery jquery-selectors operators

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -