Assigning Multiple Classes For Click Event Using jQuery

I have an click event that I want to assign to more than one class. The reason for this is that I'm using this event on different places in my application, and the buttons you click have different styling in the different places.

I have used following method and it worked for me. You can select multiple classes at once with jQuery like this:
$(".class1, .class2").click(function(){
   alert("clicked");    
});​
Fiddle: http://jsfiddle.net/Afg5s/1/

In this way you can assign more than one class for any event using jQuery.

Source: http://stackoverflow.com/a/10511922

Comments

Popular Posts