Solved

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

Posted on 2013-12-24
4
331 Views
Last Modified: 2013-12-24
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
Comment
Question by:Ashraf Hassanein
  • 2
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 500 total points
ID: 39737533
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
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 39737536
var className = $("#checklocalemail").attr('class');
0
 

Author Comment

by:Ashraf Hassanein
ID: 39737573
Thank you so much this :
   $( "#mydiv" ).hasClass( "foo" )
   has helped me.
0
 

Author Closing Comment

by:Ashraf Hassanein
ID: 39737574
Fast complete support
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jquery tab header text 1 23
Responsive Font Size 6 30
How to get total count of passed in subject based on marks? 7 20
I'm a Human captcha checkbox 13 23
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question