Answers for "jquery if element has class that starts with"

19

jquery hasclass

if ($( "#foo" ).hasClass('className')) {
	$( "#foo" ).removeClass( 'className');
} else {
  $( "#foo" ).addClass( 'className');
}
Posted by: Guest on July-01-2020
0

how to check if an element starts with class in jquery

/*SM*/

//Try using :
$("[class^=info_]"); //Classes Starts with  info_
$('[class*=info_]');  // Classes which contains info_

//instead of hasClass
if($('label').is('[class*=info_]')){} //Contains
//or
 if($('label').is('[class^=info_]')){} //Starts with
Posted by: Guest on July-20-2021

Code answers related to "jquery if element has class that starts with"

Code answers related to "Javascript"

Browse Popular Code Answers by Language