Jquery 如何在galleria中添加可选文本?

Jquery 如何在galleria中添加可选文本?,jquery,Jquery,如何使用jquery.galleria.js在缩略图和大图中添加替代文本 $(窗口).load(函数(){ 加莱里亚酒店http://www.bulogjatim.com/wp-content/themes/duotive-fortune/js/jquery.galleria.template.js'); 元(“#凯丹”)。凯丹({ 宽度:880, 身高:439, 过渡:“fadeslide” }); ); 向对象添加文本: $("#galleria").append("your text

如何使用jquery.galleria.js在缩略图和大图中添加替代文本

$(窗口).load(函数(){
加莱里亚酒店http://www.bulogjatim.com/wp-content/themes/duotive-fortune/js/jquery.galleria.template.js');
元(“#凯丹”)。凯丹({
宽度:880,
身高:439,
过渡:“fadeslide”
});
);

向对象添加文本:

$("#galleria").append("your text here");
并将HTML对象设置为图像:

$("#id").html('<img="path/to/your/file.png"/>); 
$(“#id”).html(');

您可以通过向
img
标记添加
data
属性来实现这一点

例如,
数据层
将在图像上写入标题

用法示例:

    <img data-layer="my caption" src="image.jpg" >
我希望这对你有所帮助

资料来源:

工作示例:

  • 由于@gsinha报告了我的示例代码中的一个bug并提供了一个解决方案,我更新了答案

谢谢,但是哪个数据属性用于设置图像的备用A属性。我不想设置标题/标题,我想为SEO图像添加备用文本。@KaushaMehta,根据您的评论,我已经编辑了我的答案。我添加了您给出的代码,但没有获得备用文本。@Andy“alt”标记与您的代码一起出现在活动图像上,但没有出现在所有其他缩略图图像上。我通过以下方式修复了它:
Galleria.ready(function(){this.bind('image',function(e){e.imageTarget.alt=“my alt text”;});this.bind('thumbnail',function(e){e.thumbTarget.alt my alt text”;});
@gsinha谢谢你的评论。我测试了它,你是对的,所以我更新了答案。@Valerij谢谢你编辑我的问题。很好的堆栈溢出图标。
$(document).ready(function() {
  Galleria.loadTheme('/js/jquery.galleria.template.js');
  Galleria.run('.galleria');
  Galleria.ready(function() {
    this.bind('image', function(e) {
      // add alt to big image
      e.imageTarget.alt = e.galleriaData.original.alt;
    });
    this.bind('thumbnail', function(e) {
      // add alt to thumbnails image
      e.thumbTarget.alt = e.galleriaData.original.alt;
    });
  });
});