views:

45

answers:

3

For hover, I do this:

$('.btn').hover(function (event) {
   $(this).toggleClass('hover');
});

Is there any similar workaround for :active? Need it for the damned IE6.

Thanks!

+1  A: 

Theres some info on here:

http://csscreator.com/node/31976

+3  A: 

You can use jQuery mousedown() to simulate this.

Look at the example here:

http://api.jquery.com/mousedown/#example-0

$('.btn').mousedown(function(){
    $(this).addClass('active');
}).mouseup(function(){
    $(this).removeClass('active');
});
Fred Bergman
Thanks, it works, but its not smooth, hmm....
Nimbuz
A: 

You can do it the lazy way, just intercepting a mousedown event.

 $('.btn').mousedown(function (event) {
      $(this).toggleClass('active');
 });

or do it the cool way, write a special event for it.

jAndy
Nope, doesn't work well, also needs mouseup to function correctly.
Nimbuz
yes, .mouseup is needed to remove the class indeed. But what do you mean with "doesn't work well"?
jAndy