Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
64
rated 0 times [  67] [ 3]  / answers: 1 / hits: 132063  / 11 Years ago, fri, june 21, 2013, 12:00:00

I've been trying to find code to simulate mouseover in Chrome but even though the mouseover listener gets fired, the CSS hover declaration is never set!



I tried also doing:



//Called within mouseover listener
theElement.classList.add(hover);


But nothing seems to change the element to what is declared in its hover declaration.



Is this possible?


More From » jquery

 Answers
57

You can't. It's not a trusted event.



Events that are generated by the user agent, either as a result of user interaction, or as a direct result of changes to the DOM, are trusted by the user agent with privileges that are not afforded to events generated by script through the DocumentEvent.createEvent("Event") method, modified using the Event.initEvent() method, or dispatched via the EventTarget.dispatchEvent() method. The isTrusted attribute of trusted events has a value of true, while untrusted events have a isTrusted attribute value of false.


Most untrusted events should not trigger default actions, with the exception of click or DOMActivate events.



You have to add a class and add/remove that on the mouseover/mouseout events manually.


[#77506] Wednesday, June 19, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
paola

Total Points: 675
Total Questions: 115
Total Answers: 95

Location: Laos
Member since Tue, Jul 7, 2020
4 Years ago
;