How to get classname of selected element in jquery

satinder singh / Updated : / 0 Comments

 jQuery .attr(): This article explain how to get class name or Fetch class name of element i.e Div, UL, li or any other HTML tag. You can also check my previous post on Learn jQuery, where have explained how to add click event on dynamically added element, and how to preview image before upload on server.


Add div tags, with some class.

<div id="content" class="foo boo">
  Click Me

jQuery: code to get class name on button click

  var getClassName=$(this).attr("class");


Post Comment

Your email address will not be published. Required fields are marked *