Is livequery deprecated

后端 未结 2 900
没有蜡笔的小新
没有蜡笔的小新 2020-12-08 22:11

I\'m looking at old code. I\'m seeing that for elements that get added with ajax, there\'s lots of livequery code. Is livequery not needed anymore with the newer versions of

2条回答
  •  北海茫月
    2020-12-08 22:44

    You have to use on() and attach the event to a parent or body. Ex :

    $('#obj').livequery('click', function() { ... });
    $('#obj').livequery(function() { ... });
    

    become

    $('body').on('click', '#obj', function() { ... });
    $('body').on('DOMNodeInserted','#obj', function() { ... });
    

    note that DOMNodeInserted is IE9+

提交回复
热议问题