user944513
user944513

Reputation:

how to add active class in jQuery?

Can you please tell me how to add active class in jQuery. So that user know it is selected and unselected button?

Here is my fiddle http://jsfiddle.net/GG7ZZ/48/

$(document).ready(function(){
  $("#btn").click(function(){
    $("#btn").addClass('highlight')
  });
});

Upvotes: 0

Views: 137

Answers (1)

Chandranshu
Chandranshu

Reputation: 3669

Here you go: http://jsfiddle.net/GG7ZZ/52/

   button:active {
       background: yellow;
   }

You don't even need javascript for this. Just add the above CSS and it'll do what you want.

Upvotes: 1

Related Questions