0

I'm trying to test for the presence of class intra-field-label on an element. This element will have multiple classes. How may I do this?

2
  • Don't feel bad but before posting it on stackoverflow, make sure that question you are posting worth posting on stackoverflow, bcoz you can easily get the solution using google also. Commented Mar 29, 2011 at 3:48
  • Before Google, you should probably consult the actual documentation Commented Mar 29, 2011 at 3:49

4 Answers 4

6

Use hasClass()

http://api.jquery.com/hasClass/

Sign up to request clarification or add additional context in comments.

Comments

1
if ($("#yourelementid").hasClass("intra-field-label")) {
    // your code goes here
}

Comments

1

For completeness, there's also .is() which takes any jQuery selector. This is more flexible, but for your particular case, Phil's answer is more appropriate.

Comments

0

The jquery selector for class is ".class", http://api.jquery.com/class-selector/

$('.intra-field-label')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.