javascript - Changing img source by clicking button -
i want replace number in image src (eg. eyes1 eyes2) when click button.
moverightbtn.on('click', function(){ var eyesimg = $('#eyesimg').get(0).src; console.log(eyesimg) // <--- folder/folder/folder/img/eyes1.png //iterate 1 (eg. eyes1.png eyes2.png) , change src? }
what best way this?
just expand on pmandell answer, keep increment (if that's want do)
also, seems image has id of eyesimg, i've taken account also
var counter = 0; moverightbtn.on('click', function(){ $('#eyesimg').attr('src','folder/folder/folder/img/eyes' + counter + '.png'); counter++ }
edit
here's example involving cats. cats help
http://jsfiddle.net/alexjamesbrown/6cve9/
Comments
Post a Comment