replacing jquery.live() with jquery.on() doesn't work

后端 未结 3 1482
时光说笑
时光说笑 2021-01-01 10:14

I have several textboxes that are added dynamically after an ajax call. These boxes are tied to event handlers with .live() that currently work fine. I want to replace that

3条回答
  •  时光取名叫无心
    2021-01-01 10:43

    Heres the example they have, but with the delegate:

    http://jsfiddle.net/HDtz3/

    vs non-delegate: http://jsfiddle.net/HDtz3/1/

    This is why i hate the new on syntax.

    In yours simply do:

    $('#MainDiv').on({
      mouseenter: function () { .... },
      mouseleave: function () { .... },
      blur: function () { ... }
    }, '.MyTextBox');
    

    and it should work

提交回复
热议问题