简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM