I've got an element whose css is altered under :hover
. I've also got some javascript that changes the height of the element. However if the javascript fires while the :hover
state is active the state remains even though the height change moves the element out from underneath the mouse.
Also since the javascript is fired by a click event within the element. This effect occurs on touch screens too.
I want to know if there's some way of coping with this issue. Can I force the browser to re-calculate hover (or mouseover etc)? Looking at this question, I'm not optimistic.
I've created a fiddle to demonstrate the issue.
I guess if the worst comes to the worst I could do it all manually with classes, mouseenter
, mouseleave
and DOMAttrModified
. But that sounds like a pain and may even be costly in terms of javascript (I'll have to manually identify whether the mouse sits within the bounds of my elements).
UPDATE
OK, so I really can't touch DOMAttrModified
, the performance hit is massive.
The location reload() method in HTML DOM is used to reload the current document. This method refreshes the current documents. It is similar to the refresh button in the browser.
“MutationObserver” is a Web API provided by modern browsers for detecting changes in the DOM. By using this API you can listen to changes in DOM, like added or removed nodes, attribute changes or changes in the text content of text nodes and make changes. Web apps are getting complex on the client-side nowadays.
jQuery hover() Method The hover() method specifies two functions to run when the mouse pointer hovers over the selected elements. This method triggers both the mouseenter and mouseleave events. Note: If only one function is specified, it will be run for both the mouseenter and mouseleave events.
element.parentNode.replaceChild(element, element);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With