Javascript : Access data-link attribute

187 Views Asked by At

https://151megapixel.co.nz/concrete5/index.php/gallery

I have a javascript generated slideshow using SmartPhoto (so I can get the zoom facility). However, I wish to make the data-caption a link through to another page. I cannot post the javascript code here as it is over 1000 lines.

I have tried:

data-link="/concrete5/index.php/purchase"

$(".aclick").click(function (e) {
        e.preventDefault();
        alert($(this).find('data-caption').attr("data-link"));
        });
1

There are 1 best solutions below

3
hco On BEST ANSWER

I checked the link you provided. As I understood, you can write like below:

$('a.js-smartPhoto').click(function (e) {
    e.preventDefault();
    alert($(this).data('link'));
});