Jquery 如何在galleria中添加可选文本?
如何使用jquery.galleria.js在缩略图和大图中添加替代文本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
$(窗口).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并提供了一个解决方案,我更新了答案
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;
});
});
});