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

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -