简体   繁体   English

jQuery Cycle Scrubber插件:添加图像链接

[英]Jquery cycle scrubber plugin: adding links to images

I'm using this jquery plugin which lets you scrub through images: http://thespiral.ca/jquery/scrubber/demo/ 我正在使用这个jquery插件,它可以让您浏览图像: http : //thespiral.ca/jquery/scrubber/demo/

I'm trying to add a link to each image, like this for example: 我正在尝试向每个图像添加链接,例如:

<div id="basic">
<a href="google.com"><img src="images/beach1.jpg" width="200" height="200" alt="Beach1" /></a>
<a href="yahoo.com"><img src="images/beach2.jpg" width="200" height="200" alt="Beach2" /></a>
<a href="bbc.com"><img src="images/beach3.jpg" width="200" height="200" alt="Beach3" /></a></div>

But something in the script seems to be blocking links, and no matter what I do the image have a "#" link. 但是脚本中的某些内容似乎阻止了链接,并且无论我做什么图像都具有“#”链接。

Can anyone help? 有人可以帮忙吗?

Update: I put up a jsFiddle: http://jsfiddle.net/qdGXZ/ 更新:我放了一个jsFiddle: http : //jsfiddle.net/qdGXZ/

The problem may be in jquery.cycle.all.min.js . 问题可能出在jquery.cycle.all.min.js There is a code in it that may cause this kind of behaviour. 其中有一个代码可能会导致这种行为。 Here it is: 这里是:

else{a='<a href="#">'+(i+1)+"</a>";}

Comment it and see what happens. 评论它,看看会发生什么。 This was the only piece of code in the given example that could cause this. 这是给定示例中唯一可能导致此问题的代码。 To fix this you need to pass href attribute defined by you to the else case and do something like this: 要解决此问题,您需要将您定义的href属性传递给else案例,并执行以下操作:

else{a='<a href="'+el.attr("href")+'">'+(i+1)+"</a>";}

I don't know if this will help. 我不知道这是否有帮助。 Just can't do much. 只是做不了什么。 Now you know what is the problem and what you should do to fix it. 现在您知道了问题所在以及应采取的措施。 The rest is up to you. 其余的取决于您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM