I have following HTML code snippet.
<li my-id="10" class="my-class">test-1</li>
<li my-id="15" class="my-class">test-2</li>
<li my-id="20" class="my-class">test-3</li>
Can anybody help me how to get the id of the above one html element when a click event is occur. When explaining more, I have following code in jquery. When a user clicks on any of the above element I need to extract the id corresponds to same element. I use following code in jQuery.
$('.my-class').on('click', function(e) {
var ids = e.targetElement.attr('my-id');
});
But the above code snippet is not working. Can anybody suggest better method to do this ?