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

Delphi change the assembly code of a running process -

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

C++ 11 "class" keyword -