I found some code for an 'image slider' on this site, which I'm trying to change to suit my needs. I want to be able to step through 3 or 4 image files, but I'll settle for two, until I get this code sorted.
Could you help me fix this code? I have two images, img1_on.png and img2_on.png.
<img id ="rotate_images" src="img1_on.png"/>
$('rotate_images').on({
'click': function() {
var src = ($(this).attr('src') === 'img1_on.png')
? 'img2_on.png'
: 'img1_on.png';
$(this).attr('src', src);
}
});
It worked when instead of $('rotate_images').on I had $('img').on. So I get what's happening - 'when you click on any image on the page, if the current image isn't img1_on.png, then show img1_on.png...but I want the code to apply to a SPECIFIC div of images, not any image.
Any help would be appreciated.
Chris.