如何在幻灯片中添加链接到每个图像?

我使用了“为什么这个幻灯片闪烁?”中的代码。 彼得在网站上给出了你的一个答案,它完美无缺,没有任何闪烁,但我的问题是如何为每个图像添加超链接。 我已粘贴代码供您参考

脚本

(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($("").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); }); })();  

请帮忙……………..

在这之后:

 $("#slideShow").prepend($("").attr("src",url)); 

尝试添加此function

 $('#slideshow img').wrap(''); 

您需要将位置更改为您希望链接的位置

在你的行上:

 $("#slideShow").prepend($("").attr("src",url)); 

(我真的不知道JQuery或者这是什么,我确实理解Javascript + HTML,但是)

你能加一个:

 .attr("onClick",JAVASCRIPTNAMEHERE) 

到最后?

 $("#slideShow").prepend($("").attr("src",url).attr("onClick","window.Navigate('www.Google.com')"); 

代替

 $("#slideShow").prepend($("").attr("src",url)); 

尝试使用

 $("#slideShow").prepend($("")); 

HTH