Get the data-target dynamically

javascript, jquery, twitter-bootstrap

Solution

You need `#productVariantModal` right ? So.Simple use `attr`

var getValue = $('.popup').attr("data-target");

if it dynamically

var getValue = $(this).attr("data-target");

WORKING DEMO

Problem

I have the follwing link: ``` <a href="edit/2" class="popup" data-toggle="modal" data-target="#productVariantModal"> <span class="glyphicon glyphicon-edit"></span></a> ``` I would like to get the data-target dynamically so I could reuse my javescript code. I have tried something like this: ``` var target = $(this).closest('[data-target]'); ``` But this does't work. Any Suggestions are welcome. Thanks.

Original source