Search code examples
javascriptgallerydata-linking

Javascript : Access data-link attribute


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"));
        });

Solution

  • 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'));
    });