Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
117
rated 0 times [  119] [ 2]  / answers: 1 / hits: 37754  / 10 Years ago, sun, may 11, 2014, 12:00:00

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.


More From » jquery

 Answers
5

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


[#71085] Friday, May 9, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byronkodyo

Total Points: 552
Total Questions: 87
Total Answers: 104

Location: Burundi
Member since Sat, Aug 21, 2021
3 Years ago
;