JavaScript 中的 onclick="delRow (this) 用 jQuery 该如何写呢?
'<button type="button" class="btn btn-danger btn-xs" onclick="delRow(this)">DELETE</button>'
点击Delete后删除一行
function delRow(obj) {
$(obj).parent().parent().remove();
}
以上没问题,但是想用jquery 写; 我自己尝试只能删除一次,想问下是我哪里出了问题了吗?
'<button type="button" class="btn btn-danger btn-xs" id="tt" >DELETE</button>'
$('#tt').click(function () {
$(this).parent().parent().remove();
})
推荐文章: