更新时间:2023-11-30 22:37:34
它应该是这样的:
$( document ).on("click", "tr[role='row']", function(){
alert($(this).children('td:first-child').text())
});
简要说明:
首先,DOM中没有元素存在于应用点击事件,即 div [role ='row']
。其次,你必须动态绑定click事件,因为绑定click事件的时间, DataTable
没有完全加载,并且还没有这样的元素存在你应用click事件。
Brief Explanation:
First of all there is no element exists in DOM on which you are applying click event i.e. div[role='row']
. Secondly, you have to dynamically bind click event, because the time you bind click event, DataTable
was not fully loaded and there were no such element existed yet on which you are applying click event.