继续提问Use classes of dynamically loaded html with Jquery
$(".content-white").on('click', ".product", function () {
var id = $(".product").attr('id');
alert(id);
});
如何获得带有类产品的元素才能获得它的ID?
答案 0 :(得分:2)
您可以使用this
来引用事件处理程序中的目标元素
$(".content-white").on('click', ".product", function () {
var id = this.id;//this here refers to the dom element which was targeted by the handler
alert(id);
});