I was just trying to get data-id of an html element by refering the previously solved issue in stackoverflow.I am exactly trying the same but getting undefined.Why is it so?
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a data-id="123" class="a">link</a>
<script type="text/javascript">
$(document).ready(() => {
$('.a').on('click',() => {
console.log($(this).attr("data-id"));
})
})
</script>
</body>
</html>