has class in jquery

if ($( "#foo" ).hasClass('className')) {
	$( "#foo" ).removeClass( 'className');
} else {
  $( "#foo" ).addClass( 'className');
}

4.4
5
Z0r 95 points

                                    $( "#mydiv" ).hasClass( "foo" )

4.4 (5 Votes)
0
4
10
Darylnak 130 points

                                    <!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>hasClass demo</title>
  <style>
  p {
    margin: 8px;
    font-size: 16px;
  }
  .selected {
    color: red;
  }
  </style>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
 
<p>This paragraph is black and is the first paragraph.</p>
<p class="selected">This paragraph is red and is the second paragraph.</p>
<div id="result1">First paragraph has selected class: </div>
<div id="result2">Second paragraph has selected class: </div>
<div id="result3">At least one paragraph has selected class: </div>
 
<script>
$( "#result1" ).append( $( "p" ).first().hasClass( "selected" ).toString() );
$( "#result2" ).append( $( "p" ).last().hasClass( "selected" ).toString() );
$( "#result3" ).append( $( "p" ).hasClass( "selected" ).toString() ) ;
</script>
 
</body>
</html>

4 (10 Votes)
0
4.38
8

                                    jQuery(Selector).hasClass('class_name');

4.38 (8 Votes)
0
4.25
8
Foad 145 points

                                    $("#EL_ID").hasClass("CLASS_NAME");

4.25 (8 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to check an element has a class in jquery check jquery class jquery see if class exists check if class exists jquery this how to check if the div clicked has class jquery check a class exist in jquery how to check if div has class jquery if a class has jquery jquery if html has class how to check class contain in div using jquery jquery check class name jquery has ccss class how to check specific id has class in jquery jquery have class check if class is here jquery jquery if elemnt contains class jquery check if it has a class get element has class jquery has class jquery syntax jquery check if div contains class how to check if an element has class in jquery jquery check if event has class how to check if a class is with jquery class contains jquery jquery click if this has class check if class contains class jquery jquery if has class show jquery check if element had class jquery check if classlist contains jquery check class contains how to check specific class contains in jquery check if an element has a class jquery if div has class then jquery jquery if find class check class exist in jquery jquery check if clicked element has class jquery check if there is an element with class check is element has class jquery body has class in jquery class exist check in jquery check if a class exists jquery jquery how to check class is present on element check if element has a class javascript jquery if has class check jquery jquery if have class check if has class in jquery jquery has class css to element check class in jquery contains class name jquery jquery has class? how to check a class exists in jquery if has class in jqueyr if jquery object has class if element class exists jquery if class contains jquery jquery if body has class jquery has class if condition jqyery has class jQuery check if element exists by class jquerry has class check if div has specific class jquery jquery on click check if has class check class exist on div jqueryr check tif element has class jquery hasclass in if condition in jquery jquery check class if exist jquery check if item has class wp if jquery hasclass jquery check class exists if has class then jquery jquery check have class hasclass() in jquery have a class jquery jquery if this has class this element check classes of element jquery how to check a div has any div with a class name in jquery jquery has class function contains class jquery how to check div has class in jquery jquery if is class check hasClass on click in jquery check class contains jquery jquery div has class jquerry if has class check if div has class jquery hasclass return jquery jquery check if contains class check for a specific class jquery jquery if class contains check div class exists jquery jqeury has class how to check if a class is in item jquery jquery check if body has class has class jquery if if has class condition in jquery if contain class jquery jquery check if element has a class jquery hasclass if check if an element has a specific class jquery how to has class in jquery check if element has class in jquery check for class name jquery check if an element has class jquery if has class, then run script jquery if document has class jquery every class that has class jquery jquery check if it has class if class exists jquery if this has class jquery hasclass jquery if condition jquery check if element does not have class check element has specific class jquery jquery check element class jquery check has class name check if element has a class jquery jquery check if hasClass jquery check if clicked element has a class jquery class contains tag has class. jquery hasclass jquery if check if it has class jquery jquery hasClassName jquery check if clicked has class name jquery check element for class check for class jquery jquery hass class how to check if an element has a particular class in jquery how to check if the current element has class in juqery how to check div has class in jquery issue check if class exists in element id jquery how to check if class exists in jquery check if class exist in jquery jquery check if element contains class check if there is a class jquery jquery test for element has specific class hasclass check in jquery check jquery class method check if div contains class jquery find if inner div has a class jquery jquery contains class name jquery check exist class jquery check if class exist jquery if this hasclass if body hasclass jquery jquery has class javascript has class check in jquery check if element has class name jquery jquery check if div have class if class has class jquery check if class exists jquery if has a class jquery jquery if elem has class jquery if div has class how to check class is exist in jquery jquery classlist contains when element has class do something jquery check element has class check if div has a class jquery jquery has a class is class jquery has class in jquery jquery check this has class jquery chch if object hs class check if has a class jquery jquery check if div has class if div has class jquery check class exist or not in jquery jquery if item has class has a class jquery if has class check if class present jquery jquery check if class exists on element check class jquery check class of div with jquery if control has class jquery jquery detect if has a class if a balise has a class jquery has class jquery element has class jquery: has class how to check has class in jquery has class function in jquery button has class or not c# element has class jquery jquery hasclasss jquery check class jq has class jqiery if div has class if form has class if element has class jquery check has class in jquery jquery if you have this class do that hasclass using jquery jquery class list contains verify if element has class jquery jquery if class exists jquery check hasclass jquery is class exist if hasclass jquery jquery if contains class kquery whent class exists jquery if class jquery check whether a class exist check the class name in jquery classlist contains jquery jquery hasCalss check if css class exists jquery jquery if have class jquery check if it has this class cehck calss in jquery jquery classlist has class jquery check class exist if class present jquery j query hasclass syntax to check wheather this class is present in this container if present then further conditions using jquery check the class in jquery how to check class using jquery jquery check if input has class have class jquery check if contain class jquery Check if object has class jquery if input has class jquery jquery check if class has class jquery check has class jquery has vlass jquery check if element has class jquery if has class how to check if an element has a class in jquery jquery if this has class jquery + hasClass jquery body has class jquery test if class exists on element jquery if hasClass css hasclass jquery to check body has class check if element has class jquery how to check element has class in jquery jquery this has class hasclass in jquery jquery if this classname - check if element has a class in jquery check if a class is present jquery if element has class selected assign another class javascript check element contains class jquery check has class jquery jquery test if element has class if class name contains jquery jquery check this had class class contains class jquery check if class has another class jquery exsist class name in jquery check class name in jquery jquery check if has class jquery checking css class jquery has class how to check if class exist in class list jquery if has class jquery check if class exist in classlist jquery has class jquery jquery if element has class jquery check if class exists jq element has class jquery verifi if a dive have a clas how to check for the class in jquery check class of element jquery jquery check if element belongs to class jquery contains class check element has class jquery jquery if has clas jquery hasclass jquery check for class check if has class jquery hasclass jquery jquery if selector has class jquery if element contains class
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source