Today, I have this little problem:
$(Document). Ready (function () {
$ ('. status_on '). Hover (function () {
$ (this). html (' click Disable ');
$ (this). css (' color ',' red ');
},function () {
$ (this). HTML (' activated ');
$ (this). css (' color ',' green ');
});
});
However, when the element that triggers the hover is JS later generated, the hover is invalid.
So the first reaction was to think of the delegate agent:
$(Document). Delegate ('. status_on ',' Hover ',function () {
$ (this). html (' click Disable ');
$ (this). css (' color ',' red ');
});
$ (document). Delegate ('. status_on ',' blur ',function () {
$ (this). HTML (' activated ');
$ (this). css (' color ',' green ');
});
Because hover is not a standard event, it cannot be processed directly using live and delegate
Similarly, Blur is.
Know the reason, the solution is very simple, with MouseEnter and mouseleave instead of hover and blur on the line:
$(Document). Delegate ('. status_on ',' MouseEnter ',function () {
$ (this). html (' click Disable ');
$ (this). css (' color ',' red ');
});
$ (document). Delegate ('. status_on ',' MouseLeave ',function () {
$ (this). HTML (' activated ');
$ (this). css (' color ',' green ');
});
Hover and blur using proxy delegate invalid workaround in jquery