slideshow with previous and next buttons to work
I am trying to get the event handler attached to my Next button to work, and then will have to do the same with a previous button. I am getting a "Not implemented" error in line 8 of the jQuery - I am newer to jQuery and Java, so not sure why this has happening and have exhausted myself trying to find out why. Besides just a fix, an explanation would be appreciated.
Buttons in HTML:
- <input type="button" id="previous" value="Previous" > <input type="button" id="next" value="Next" >
jQuery:
- var $ = function (id) {
- return document.getElementById(id);
- }
- window.onload = function () {
- var listNode = $("image_list");
- var captionNode = $("caption");
- var imageNode = $("image");
- $("next").onclick = nextImage;
-
-
- var links = listNode.getElementsByTagName("a");
-
- // Process image links
- var i, linkNode, image;
- var imageCache = [];
- for ( i = 0; i < links.length; i++ ) {
- linkNode = links[i];
- // Preload image and copy title properties
- image = new Image();
- image.src = linkNode.getAttribute("href");
- image.title = linkNode.getAttribute("title");
- imageCache.push(image);
- }
- // Next Button
- var imageCounter = 0;
- var nextImage = $(function() {
- imageCounter = (imageCounter + 1) % imageCache.length;
- image = imageCache[imageCounter];
- imageNode.src = image.src;
- captionNode.firstChild.nodeValue = image.title;
- });
- }