jnoweb jnoweb - 13 days ago 9
Javascript Question

Show a div once you onclick and continue to show until clicked again

I currently have a hover state applied to #ex:

$("#ex").hover(function(event) {
$("#prod").show();
}, function() {
$("#prod").hide(0).delay(5000);
});


However, I also want to have an onclick state applied to #prod, which continues to show, but at the moment it doesn't because of the line I've coded above:

$("#prod").hide(0).delay(5000);


Any ideas???

Answer

Use stop() method to stop the animation.

$("#prod").stop().show();


Or as @freedomn-m suggested - finish() method can be used.

$("#prod").finish().show();