문제

What is the correct way to get the same functionality of live(), and on() in jQuery < 1.5.

도움이 되었습니까?

해결책

You need to use .delegate

 $( "table" ).delegate( "td", "click", function() {
  alert($(this).html());
});

다른 팁

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

.on() is for jQuery version 1.7 and above. If you have an older version, use this:

$("#SomeId").live("click",function(){
    //do stuff;
});

But you can use live() because you are using jQuery<1.5

use delegate https://api.jquery.com/delegate/ works for jQuery 1.4.3+

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top