Reputation: 1459
I am trying to implement a simple script of image thumbnails, that when clicked, display a larger image.
I am trying to do this without using an existing plugin.
Here is my current code.
$('#thumbnails ul li').click(function() {
$('#main').attr('src', $(this).attr('src').replace('small/', 'large/'));});
Can someone please let me know what I am doing wrong? I have also upload the whole code here... http://jsfiddle.net/PjrFe/
Thanks in advance guys.
Upvotes: 0
Views: 67
Reputation: 2636
that's because you're checking attr 'src' of clicked li; try this:
$('#thumbnails ul li').click(function() {
$('#main').attr('src', $(this).find('img').attr('src').replace('small/', 'large/'));
});
Upvotes: 2