57
rated 0 times
[
60]
[
3]
/ answers: 1 / hits: 19440
/ 10 Years ago, mon, september 15, 2014, 12:00:00
I'm developing an application where I need to add class active
for both hover
and click
events.
The challenge I am facing here is when I hover my content, it adds the class active
. There is no problem in that.
Since it is active now, when I am about to click on content it should hold up with the class active
. But instead it goes to the normal state and it toggles the class.
JQuery
$(div).hover(
function() {
$(this).addClass('active');
}, function() {
$( this ).removeClass('active');
}
);
$( div ).click(function(){
$(this).toggleClass('active');
});
More From » jquery