A.T. A.T. - 1 year ago 77
jQuery Question

How can i add event to mouse-in mouse out for dynamic DOM element

I manage mouse-over and mouse-out for DOM elements,


But it doesn't work for dynamic content, how can i do same for dynamic elements.

Answer Source

You can use the .on() method. Nnote that hover is a shorthand for mouseenter and mouseleave events and not mouseover and mouseout events.

Also, performance-wise, it would be better to select a closing static parent element instead of the document object.

    mouseenter: function() {
    mouseleave: function() {
}, '.selector');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download