Sunday, 2 June 2013

JQuery: Add image 'src' to 'a' tag

JQuery: Add image 'src' to 'a' tag

I am using the JQuery Cycle Plugin with thumbnails. This works fine if I use images as my slides. But I want to wrap these images in a tags. This breaks the thumbnail as the code looks for the src within the first, parent element of each slide and of course the a tag does not have this. eg:
pagerAnchorBuilder: function(idx, slide) {
    return '<li><a href="#"><img src="' + slide.src + '" width="145" height="88" /></a></li>';
}
What I want to do is some how attach the image's src to its parent element, so that the above code can read it. Something like:
<a href="page.html" class="slide" src="image.jpg"><img src="image.jpg"></a>
But it seems my browser automatically renders it out.
Does anyone know a way to get round this?

No comments:

Post a Comment