Solved

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

Posted on 2013-12-24
4
326 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
grab and show facebook pages event calendars 6 46
HTML page and JavaScript 2 55
JavaScript Scope issue 4 20
ajax form sumbit 3 30
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now