views:

62

answers:

1

Hello! I've created a sliding image viewer here. As you can see, there's 4 small clickable images to change/slide the image. I want the small image to change to this image alt text when it's clicked, or when the appropriate main image is showing. That way the users can tell which main image is being shown. Can anyone maybe look at the source and explain how to do this? Thanks!

+5  A: 

Hello, try the following code !!

var src = [];
    src['normal'] = "http://beta.d-load.org/images/etc/imagev-norm.png";
    src['active'] = "http://beta.d-load.org/images/etc/imagev-over.png";
$(document).ready(function() {
    $('a',$('.paging')).click(function() {
       $('a',$('.paging')).find('img').attr('src',src['normal']);  
       $(this).find('img').attr('src',src['active'])   ;
    });
});

Here you go, Demo : http://jsfiddle.net/qTB9g/

Ninja Dude
Only thing is that he wants to use an image, so you'll either have to set it as the background image for that class or actually change the selected image's source.
ryanulit
`@ryanulit` now, I understand what exactly he wants. Thanks for letting me know
Ninja Dude
Thanks! Although I couldn't get it to work with a background image. Any way to change an image's source from CSS?
Joey Morani
hey, I just updated the code check out http://jsfiddle.net/NfjMB/
Ninja Dude
Thanks, I'll give it a go. :)
Joey Morani
you're welcome :) Have a Nice Day !!
Ninja Dude
No problem. That code should work fine.
ryanulit
Thanks again. Just one last question now:- What do I do if there's other images on the same page which have been hyperlinked? The code seems to replace them images with the 'normal' or 'active' images. Is there a way to use something else other than "$('a').find('img')", as from my understanding (which is very little); that's looking for all images which are hyperlinks.
Joey Morani
@Joey Updated !!!
Ninja Dude
Thanks!! Works great. You've helped me a lot. :)
Joey Morani