Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove :hover?

I have a small problem with a script.
I want to have a default action on :hover for clients with Javascript disabled, but for those with Javascript enabled I want another action (actually... same action, but I want to add a small transition effect).

So... How can I do this? I am using jQuery.

like image 601
Ionuț Staicu Avatar asked Jan 12 '09 19:01

Ionuț Staicu


People also ask

How do you remove the hover from an element?

One method to do this is to add: pointer-events: none; to the element, you want to disable hover on. (Note: this also disables javascript events on that element too, click events will actually fall through to the element behind ).

How do I get rid of hover in WordPress?

Go to the WordPress Customizer > Additional CSS tab and write the following CSS. This code will take care of the hover state and the current menu item state as well. For the second question In the next updates I will add some generic colorpickers you can use to change some color styles. Cheers!

How do I enable hover in CSS?

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.


2 Answers

Apply two classes to the relvant element. one contains the hover behaviour, and one contains all the other styling.

You can then use the jquery

$(element).removeClass('hover'); 

method to remove the class with the hover behaviour and then apply whatever you want using

$(element).bind('mouseover', function () { doSomething(); }); $(element).bind('mouseout', function () { doSomething(); }); 
like image 99
benlumley Avatar answered Sep 23 '22 01:09

benlumley


How about putting the :hover fall-back in a stylesheet that is only loaded if javascript is disabled?

<noscript>   <link href="noscript.css" rel="stylesheet" type="text/css" /> </noscript> 
like image 43
foxy Avatar answered Sep 22 '22 01:09

foxy