0

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 http://beta.d-load.org/images/etc/imagev-on.png 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!

1 Answer 1

4

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/

Sign up to request clarification or add additional context in comments.

4 Comments

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 now, I understand what exactly he wants. Thanks for letting me know
Thanks! Although I couldn't get it to work with a background image. Any way to change an image's source from CSS?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.