Continue of question Use classes of dynamically loaded html with Jquery
$(".content-white").on('click', ".product", function () {
var id = $(".product").attr('id');
alert(id);
});
How can I get an element with class product to get it's id?
You can use this
to refer to the targeted element within the event handler
$(".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);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.