if element has class

/ Published in: jQuery
Save to your folder(s)

Found this, very useful

Copy this code and paste it in your HTML
  1. if ($(#elm).is('.first')) {
  2. //#elm has the class
  3. } else {
  4. //#elm doesn't have the class
  5. }

URL: http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.