Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

How to check which class was added in Ajax after adding it?

I have Ajax functions where sometimes I am adding class called red  to a radio button using this code:
        $("#checklocalemail").addClass("green");
       or
         $("#checklocalemail").addClass("red");
I want to verify later what is the last class is add, but how can I retrieve that?
      I have checked anf I found that this can be used by .find () but it is not clear to me how to use it, as I can not find much examples for it, can someone help please?
0
Ashraf Hassanein
Asked:
Ashraf Hassanein
  • 2
  • 2
1 Solution
 
chaitu chaituCommented:
The .hasClass() method will return true if the class is assigned to an element, even if other classes also are. For example, given the HTML above, the following will return true:


$( "#mydiv" ).hasClass( "foo" )

http://api.jquery.com/hasClass/
0
 
chaitu chaituCommented:
var className = $("#checklocalemail").attr('class');
0
 
Ashraf HassaneinAuthor Commented:
Thank you so much this :
   $( "#mydiv" ).hasClass( "foo" )
   has helped me.
0
 
Ashraf HassaneinAuthor Commented:
Fast complete support
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now