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?
Ashraf HassaneinAsked:
Who is Participating?
 
chaitu chaituConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.