PacPac PacPac - 2 years ago 87
jQuery Question

Get the data element value after clicked in jQuery

I have this type of link:

<a href="#" data-module="planning">Planning</a>

If I want to detect the click on this type of link, I use:

$("a[data-module ='*']").click(function() {

But how can I get the
value ?


Answer Source

Use jquery attr API :

$("a[data-module ='*']").click(function() {
    var dataModule = $(this).attr('data-module');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download