Responding to click event of element added to document after page load

前端 未结 6 1640
无人及你
无人及你 2020-12-12 00:54

I am writing a page which uses a lot of in situ editing and updating using jQuery for AJAX.

I have come accross a problem which can best be summarized by the workfl

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 01:28

    live is deprecated, use .on() like such:

    $('#table tbody').on('click', 'tr', function(e){
        var row = $(this).find('td:first').text();
        alert('You clicked ' + row);
    });
    

提交回复
热议问题