- english
- francais
- italiano
$('li').click(function () {
alert($(this).data('val'));
});
See DEMO.
Keep in mind that if you want to use the ES6 arrow function syntax, you cannot use this
and you need to use e.currentTarget
instead, where e
is the event object passed as the first parameter to the event handler:
$('li').click(e => alert($(e.currentTarget).data('val')));
See DEMO.