JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" data-test="some text">click me</a>
JavaScript
$('a').on('click', getAnchor);
function getAnchor(e){
e.preventDefault();
console.log($(this).data('test'));
}
<a href="#" data-test="some text">click me</a>
$('a').on('click', getAnchor);
function getAnchor(e){
e.preventDefault();
console.log($(this).data('test'));
}