Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop hover effect after click

Tags:

jquery

I have a pretty simple problem in jQuery, and I can't seem to find a solution: I have a mouseOver and mouseOut effect, but I need a twist, if click than keep that box open even though their is a mouseOut.

Here's an example of what I have so far :

jsfiddle

Thanks in advance !

like image 981
Sebastien Crapoulet Avatar asked Jul 09 '12 10:07

Sebastien Crapoulet


People also ask

How do I turn off hover effect?

To remove the CSS hover effect from a specific element, you can set the pointer-events property of the element (the hover behavior of which you want to disable) to “none”.

How do you prevent sticky hover effects for buttons on touch devices?

preventDefault() within ontouchstart or ontouchend. It appears to stop the hover effect when the button is touched, but it also stops the button click animation and prevents the onclick function from being called when the button is touched, so you have to call those manually in the ontouchstart or ontouchend handler.

How does the hover selector work?

The :hover selector is used to select elements when you mouse over them. Tip: The :hover selector can be used on all elements, not only on links. Tip: Use the :link selector to style links to unvisited pages, the :visited selector to style links to visited pages, and the :active selector to style the active link.

Does Z index affect hover?

If an element is transparent and the element with z-index:-1; is 'under' it. This stops the hover effects. Z-index can you see as elevations in a building, and you watching it from birdseye. You can't reach the basement if there is a floor above it, even if its build from glass.


2 Answers

$(".rock").click(function() {
      $('.rock').unbind('mouseout');
});

Unbind the mouseout event at .rock click.

like image 142
Jithin Avatar answered Nov 09 '22 22:11

Jithin


You have to unbind the events, then it stays open forever.

Made you an updated fiddle here

like image 41
Beat Richartz Avatar answered Nov 09 '22 23:11

Beat Richartz