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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -