简体   繁体   中英

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/

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/

The problem may be in 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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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