我有一些可以改变 id 的东西。我想调用当前 id 的函数。这就是我所拥有的(没有响应):
approvebutton = present_item.append("<div class='tableItem'><a href='#' id='"+itemIndex+"' onclick(alert(this.id))>"+ "approve" +"</a></div>");
最佳答案
$('.tableItem > a').on('click', function(){
var $link = $(this);
console.log("This is my id: "+ $link.attr('id') );
//do stuff with the link
});
关于javascript - Onclick函数获取id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30358201/