Want a free Ebook & latest Update Subscribe Now
  [email protected]      beta

How to get classname of selected element in jquery

 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");


Satinder Singh

Hi all, am Founder and Author of Codepedia.info, also atypical polyglot programmer from Bombay, India. I have a passion to create, solve, and deploy software applications.
       ForEach ( minute in MyLife ) { myExperience++ ; }

Post Comment

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