当前位置: 动力学知识库 > 问答 > 编程问答 >

escaping - How to add links to featherlight gallery afterContent

问题描述:

I use the afterContent functunality to add captions to a gallery.

<script>

$(document).ready(function(){

$('.all-imgs').featherlightGallery({

filter: ".img-box-img a",

afterContent: function() {

var caption = this.$currentTarget.find('img').attr('data-caption');

this.$instance.find('.caption').remove();

$('<div class="caption">').text(caption).appendTo(this.$instance.find('.featherlight-content'));

},

variant: "featherlight-gallery2",

});

});

</script>

How do I have to escape links in the img elements data-caption attribute so that the browser renders them as links?

My usecase is to add a link to the fullsize image in the gallery.

Thanks

分享给朋友:
您可能感兴趣的文章:
随机阅读: