javascript - How can I access current html elements certain property value? -
this js/jquery code in trying access current button clicked, class of delete, , property data-id's value. when console.log string hope have says undefined? suggestions on doing wrong?
$(".delete").click(function(){ var id = $(this).prop("data-id"); console.log(id); });
since data-* attribute need use attr()
var id = $(this).attr("data-id"); or can data-* attribute value using data()
var id = $(this).data("id");
Comments
Post a Comment