my jQuery not work and $(this) refers to document
$(function(){
$('.delete').on('click', (e)=> {
console.log($(this).data('id'));
});
// or
$('.delete').click( (e)=> {
console.log($(this).data('id'));
});
});
So I try this and it works because $(this) refers to true element:
$('.delete').click( function () {
console.log($(this).data('id'));
});
// or
$('.delete').on('click', function () {
console.log($(this).data('id'), $(this).val());
});
What is the reason for that?