Cycle Plugin Image preview
Hi
I'm trying to get an image preview in a Cycle gallery when clicking on navigation buttons like this:
- <script type="text/javascript">
- $(document).ready(function() {
-
- $('#gallery').cycle({
- fx: 'fade',
- timeout: 0,
- speed: 1000,
- delay: -2000,
- pager: '#pager',
- next: '#next',
- prev: '#prev'
- });
- $('#pager a').click(function(evt) {
-
- //path to new preview
- var imgPath = $('#gallery a').attr('href');
-
- //get reference to old preview
- var oldPrev = $('#preview img');
-
- //create HTML for new image
- var newPrev = $('<img src="' + imgPath +'">');
-
- //make new image invisible
- newPrev.hide();
-
- //add to the #photo div
- $('#preview').prepend(newPrev);
-
- //fade in new image
- newPrev.fadeIn(850);
-
- //fade out old Prev and remove from DOM
- oldPrev.fadeOut(850,function(){
- $(this).remove();
- });
-
- }); // end click
-
-
- }); // end ready()
- </script>
- </head>
- <body id="twoCol">
- <div id="container">
- <div id="contentWrap">
- <div id="main">
- <h1>Cycle Slideshow</h1>
- <div id="controls">
- <span id="prev" class="control">Previous</span>
- <span id="pager"></span>
- <span id="next" class="control">Next</span>
-
- </div>
- <div id="gallery">
- <div><a href="images/mid/blue.jpg"></a><img src="images/large/blue.jpg" width="400" height="300" alt="Blue"><p class="credit">Photo by Alin Nan</p></div>
- <div><a href="images/mid/yellow.jpg"></a><img src="images/large/milk.jpg" width="275" height="432" alt="Milk Fruit Explosion"><p class="credit">Photo by David Kitchenham</p></div>
- <div><a href="images/mid/green.jpg"></a><img src="images/large/fan.jpg" width="300" height="400" alt="Fan"><p class="credit">Photo by Jeltovski</p></div>
- <div><a href="images/mid/orange.jpg"></a><img src="images/large/red.jpg" width="400" height="300" alt="Red"><p class="credit">Photo by Alin Nan</p></div>
- <div><a href="images/mid/purple.jpg"></a><img src="images/large/weight.jpg" width="275" height="414" alt="Pink weight"><p class="credit">Photo by David Pattee</p></div>
- </div>
-
- <div id="preview"></div>
- </div>
- </div>
-
- </div>
But I only get always the same first image => <a href="images/mid/blue.jpg"></a>
What I'm doing wrong?
Any help appreciated!