Monday 15 September 2014

Jquery 2.0 mouseenter is not working for the new elements -


Hi I'm trying to add an event to the newly added element but it is not working for me Explain.

  & lt; Div class = 'btn' & gt; Button & lt; / Div & gt; & Lt; Script & gt; $ ('.btn'). After ({click: function () {$ (".btn: last"). Later ("

event lection ... < P> If you use .on () , then it works:

  $ (document) .on ({click: function () { $ ("." "" "" "" "" "" "" "" "" "" {Console.log ("outside");}}, '.btn');   

The way you used it by using .on () is $ ('.btn') Is using.) Good for static elements. But when your goal is dynamically added, you need to pass the nearest stationary parent (in this case document ) and dynamic selector ( .btn ) .

See the Direct and Assigned Events section in the information page I can tell guest jQuery better than this.

No comments:

Post a Comment