div background color, to change onhover

The “a:hover” literally tells the browser to change the properties for the <a>-tag, when the mouse is hovered over it. What you perhaps meant was “the div:hover” instead, which would trigger when the div was chosen. Just to make sure, if you want to change only one particular div, give it an id (“<div id=’something’>“) … Read more

How to prevent sticky hover effects for buttons on touch devices

Since this part of CSS Media Queries Level 4 has now been widely implemented since 2018, you can use this: @media (hover: hover) { button:hover { background-color: blue; } } Or in English: “If the browser supports proper/true/real/non-emulated hovering (e.g. has a mouse-like primary input device), then apply this style when buttons are hovered over.” … Read more

jQuery: trigger a hover event from another element

Try this: $(‘.initiator’).on(‘mouseenter mouseleave’, function(e) { $(‘.receiver’).trigger(e.type); }) It will apply the same triggers for the receiver as the initiator receives for both mouseenter and mouseleave. Note that: .hover(over, out) is just a high-level variant of: .on(‘mouseenter’, over).on(‘mouseleave’, out) so using that information you can be more precise when binding and triggering mouse events. As … Read more

How to tell .hover() to wait?

This will make the second function wait 2 seconds (2000 milliseconds) before executing: $(‘.icon’).hover(function() { clearTimeout($(this).data(‘timeout’)); $(‘li.icon > ul’).slideDown(‘fast’); }, function() { var t = setTimeout(function() { $(‘li.icon > ul’).slideUp(‘fast’); }, 2000); $(this).data(‘timeout’, t); }); It also clears the timeout when the user hovers back in to avoid crazy behavior. This is not a very … Read more

hover on child without hover effect on parent [duplicate]

Basically you can’t : How to style the parent element when hovering a child element? But a trick is to use a sibling element : http://jsfiddle.net/k3Zdt/8/ .parent { width: 100px; height: 100px; padding: 50px; } .child { height: 100px; width: 100px; background: #355E95; transition: background-color 1s; position: relative; top: -200px; } .child:hover { background: #000; … Read more