Markup:
<ul>
<li><a href="#" class="item-list" data-id="1">Link 1</a></li>
<li><a href="#" class="item-list" data-id="2">Link 2</a></li>
<li><a href="#" class="item-list" data-id="3">Link 3</a></li>
</ul>
In JQuery, i would select link 1 and it should be able to fetch the data-id of link1. I tried
$('.item-list').click(function(){
var link = $(this);
alert($(this).data('id'));
});
It doesn't have any result.
Oh. the list gets generated after the page is loaded. I am querying the DB to get the list. Also, it is also possible for the list to change, depending on how the user filters the dB.
Thanks.