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 .selected
using , 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
Post a Comment