javascript - Default image's display doesn't change despite the source of the image changing. -


    var allimages = [imagedata, imagedata1, imagedata2, imagedata3, imagedata4];     var count = 0;       $("#right").click(function() {       if (count < 5){       document.getelementbyid("hello").src = allimages[count];       count++;       }     }); 

to explain code, array allimages contains base64 versions of 5 images. #hello id of default image. #right id of button.

so when click #right, #hello's source supposed change 1 of images inside allimages array. however, nothing happens display when click #right.

i've tried changing source outside of right click function , when that, display of #hello correctly change. in addition that, #right click function work cause i've stuck alert inside of before activated upon click.

probably need check value of count .
quite possible count being global variable other block of code might have been updating value leading (count < 5) = false.

suggestion : try after renaming variable or removing if condition , setting hard-coded value of src attribute


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -