我正在使用 jquery cycle 插件并将每个图像包装在一个 div 标签中以使每张幻灯片居中,所有这些都是不同的宽度:
<div><img src="img1.jpg" width="522" height="347" alt=""/></div>
<div><img src="img2.jpg" width="420" height="347" alt=""/></div>
<div><img src="img3.jpg" width="231" height="347" alt=""/></div>
这工作正常,但它破坏了 pagerAnchorBuilder 脚本。
从这个页面:Jquery cycle - How can I wrap my images in span tags without breaking the thumbnail pager? ,我有这个:
pagerAnchorBuilder: function(idx, slide) {
var src = $("img", slide).attr("rel");
return '<a href="#"><img src="' + src + '" width="60" height="40" style="position:absolute; top:540px;"/></a></li>';
但是好像不行。
我确定我不需要指出我是 javascript 的新手!如果有任何提示,我将不胜感激!
有问题的页面在这里:http://wildwood-design.org/twagons.html
最佳答案
嘿,我找到了遇到此线程的任何人的答案(希望 6 个月后不是我)。将上面函数中的返回行替换为:
return '<li><a href="#"><img src="' + jQuery(slide).find('img').attr('src') + '" width="60" height="40" style="position:absolute; top:540px;"/></a></li>';
关于javascript - Jquery cycle - 在不破坏缩略图寻呼机的情况下将图像包装在 div 标签中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12694041/