Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-12-24
4
Medium Priority
?
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 2000 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

721 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