cycle - getting two images to change in onAfter function
I have 24 items I am cycling through. As each one is displayed, I have another that I want to change an icon corresponding to that item to a hover icon, and the item before back to a non-hover icon.
I have the hover icon coming up as needed, but cannot get the prior item icon to change back.
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
- <script type="text/javascript" src="http://malsup.github.com/chili-1.7.pack.js"></script>
- <script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>
- <script type="text/javascript" src="http://malsup.github.com/jquery.easing.1.3.js"></script>
- <script>
- $('#slideshow').cycle({
- fx: 'fade',
- timeout: 2000,
- after: onAfter
- });
- function onAfter() {
- $('#producttitle').html("<a href=\"" + this.href + "\"><b>" + this.title + "</b>")
- $('#productdescription').html($(this).attr('alt'))
- var currentItem = new String(this.id.substring(3, 5));
- var previousItem = new String((this.id.substring(3, 5))-1);
- //alert(previousItem);
- if (previousItem = "-1")
- {
- previousItem = "23";
- }
- document.getElementById(currentItem).style.background="url(../images/number_icon_hover.gif) no-repeat 0 0 #C4CBA9";
- //this is not working
- document.getElementById(previousItem).style.background="url(../images/number_icon.gif) no-repeat 0 0 #C4CBA9";
- };
- function changeitem(itemnumber) {
- $('#slideshow').cycle(itemnumber);
- document.getElementById(itemnumber).style.background="url(../images/number_icon_hover.gif) no-repeat 0 0 #C4CBA9";
- return false;
- }
- </script>