컨테이너를 AJAX로 업데이트합니다. 성능 측면에서 어느 것이 더 낫습니까? 의사 코드 :새로 고침 또는 live() (jQuery) 이후에 바인딩하는 것이 더 낫습니다.
$.post('get_something.php',function(data){
$('#container').html(data).find('a').bind('click',function(){
console.log('Doh!');
});
});
또는이?
$('#container a').live('click',function(){
console.log('Doh!');
});
$.post('get_something.php',function(data){
$('#container').html(data);
});
첫 번째 스크립트 – mgraph
'에()'. 그것은 권장하고 성능이 더 나은 (에'사용)'대신 바인드'의()'와 조합의 두 번째' jQuery 1.7에서 live()'- http://api.jquery.com/on/ – MarkSmits
업데이트하지 않는 요소를 통제 된 양 (1-5라고 가정 해 봅시다)이라면'bind()'가 선호됩니까? –