我使用了“为什么这张幻灯片闪烁?”中的代码。彼得在网站上给出了您的答案之一,它工作得很好,没有任何闪烁,但我的问题是如何为每个图像添加超链接。
我把代码贴出来供大家参考
Script
(function() {
// ------
// ###### Edit these.
// Assumes you have images in path named 1.jpg, 2.jpg etc.
var imagePath = "images";
var lastImage = 5;
// How many images do you have?
var fadeTime = 4000;
// var index=1;
// Time between image fadeouts.
// ------
// ###### Don't edit beyond this point.
// No need for outer index var
function slideShow(index) {
var url = imagePath + "/" + index + ".jpg";
// Add new image behind current image
$("#slideShow").prepend($("<img/>").attr("src",url));
// Fade the current image, then in the call back
// remove the image and call the next image
$("#slideShow img:last").fadeOut("slow", function() {
$(this).remove();
setTimeout(function() {
slideShow((index % lastImage) + 1)
}, fadeTime);
});
}
$(document).ready(function() {
// Img 1 is already showing, so we call 2
setTimeout(function() { slideShow(2)}, fadeTime);
delay(1000);
}); })();
</script>
请帮忙.................
在这之后:
$("#slideShow").prepend($("<img/>").attr("src",url));
尝试添加这个
$('#slideshow img').wrap('<a href="location" />');
您需要将位置更改为您想要链接所在的位置
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)