php - JQuery - Cycle multiple images with url -


i rendering php amount of images, render a href="" - images area changing when fading, url same.

how can change url , image together?

jquery cycle

the jquery cycle plugin can cycle any elment. easy way wrap each image hyperlink:

http://jsfiddle.net/lucuma/mv9s5/

<div id="slideshow">   <a href="/page/a"><img src="img1.jpg" /></a>   <a href="/page/b"><img src="img2.jpg" /></a>   <a href="/page/c"><img src="img3.jpg" /></a> </div>  $('#slideshow').cycle(); 

additionally can use slide attributes if perhaps have title want updated outside of sliders. you'd use after event. following code updates h1's hyperlink after each slide changes. sets text title of img on slide. because images wrapped in hyperlink, need line var $cur = $('img', currslideelement) img element of slide.

demo: http://jsfiddle.net/lucuma/dsk9s/2/

<h1 id="title"><a href="#"></a></h1> <div id="slideshow">   <a href="/page/a"><img src="img1.jpg" /></a>   <a href="/page/b"><img src="img2.jpg" /></a>   <a href="/page/c"><img src="img3.jpg" /></a> </div> $('#slideshow').cycle({     after:function(currslideelement, nextslideelement, options, forwardflag) {         var $cur = $('img',currslideelement);         $('#title a').text($cur.attr('title'));        $('#title a').attr('href',$cur.attr('src')).text();     } }); ​ 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -