How to get the class name using Jquery Example with demo?

Sometimes We need to get class name jquery. I don’t know which CSS available or exists class is applied to Html each div or any tag element. In this best Example I will learn jquery-attr, addClass, removeClass, toggleClass, Css with how to get the class name using Jquery. If data html element more check contain multiple classes it will return each class name.

Jquery attr(‘class’)

Jquery .attr() methods data returns the class attribute value. and then that i am going to split the data return value and get the respected class names.

Syntax

$("#yourid").attr('class');

Get class name using Jquery

index.html



   
   jQuery get class of element with multiple classes
        
         
   
   
   
      

HMTL Get Class Name Using Jquery

krutidev seo khazana 4cgandhi

jQuery – Get and Set CSS Classes

  • addClass() – included one or more classes to the selected data elements
  • removeClass() – deletes one or more classes from the selected data elements
  • toggleClass() – Switch between adding/removing classes from the selected data elements
  • Pure css() – Sets or returns the style attribute

jQuery addClass() Method










Seo khazana 1

Seo khazana 2

This is a 4cgandhi.

This is another 4cgandhi.

This is some important text!

jQuery removeClass() Method










Seo khazana 1

Seo khazana 2

This is a 4cgandhi.

This is another 4cgandhi.

jQuery toggleClass() Method










Seo khazana 1

Seo khazana 2

This is a 4cgandhi.

This is another 4cgandhi.

I hope you get an idea about get class name jquery.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment