如何为幻灯片中的每个图像添加链接? [英] How to add link to each image in the slideshow?

查看:114
本文介绍了如何为幻灯片中的每个图像添加链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了为什么此幻灯片会闪烁?"中的代码.彼得在网站上提供了您的答案之一,它工作正常,没有任何闪烁,但是我的问题是如何为每个图像添加超链接. 我已经粘贴了代码供您参考

I used the code from "Why is this slideshow flickering?" which peter has given for one of your answers in the web-site, it works perfectly fine without any flicker, but my question is how do I add hyperlink to each of the images. I have pasted the code for your reference

脚本

(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>

请帮助.........

Please Help.................

推荐答案

此后:

$("#slideShow").prepend($("<img/>").attr("src",url));

尝试添加此内容

$('#slideshow img').wrap('<a href="location" />');

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

You will need to change location to where you want the link to go

这篇关于如何为幻灯片中的每个图像添加链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆