'jquery hover not working after being moved
I want to make a "catch the button game" so I have to move a button and if I move it the hover event doesn't work anymore. I tried it with normal js but that didnt help either.
Solution 1:[1]
In the Case of the Dynamically added elements, It is better to add the event with the parent element. So you can use 'html' or 'body' tag for that.
.on(events[,selector][,data],handler)
$(document).ready(function () {
$('html').on('hover', '.btnClass', function () {
// do you work
})
});
Solution 2:[2]
Probably because you have a dynamic added element(button). Therefor you need to use the .on using jQuery. ??
$(".buttonClass").on("hover", function () {
// your function.
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Kip |
