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

后端 未结 3 1462
时光说笑
时光说笑 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:39

    Aaron, Matt, I think you've got the selector in the wrong order (for a live conversion), Have a look at the API documentation for on- http://api.jquery.com/on/#example-7

    $("body").on("click", "p", function(){
      //stuff
    });
    

    When I tried your method (I came here looking for a solution for updating my core version), console errors popped up for everything (1.8, 1.9 and 2.0). The target element should be the second parameter not the last. Not sure why your answer has been accepted as it doesn't work. Hope this helps.

提交回复
热议问题