0

JavaScript

i need help in JavaScript. Why does the image appear only after the second click on the button? https://code.sololearn.com/WfsIx9O5jqpu/?ref=app

15th May 2021, 4:34 PM
Alexander Sokolov
Alexander Sokolov - avatar
3 Answers
+ 2
you could do same much simpler (and shorter) by drawing your images in the button event listener handler functions, rather than using requestAnimationFrame and flags ;P you also could assign the result of getElementsByTagName to a variable to not query twice for them... anyway, to avoid the loading time delay you could preload both images and show the page to user only once they are ready to be used: https://code.sololearn.com/WWl7YvbuhvvC/?ref=app
16th May 2021, 3:20 PM
visph
visph - avatar
+ 1
It works! Click once and wait for some seconds the image will load.
15th May 2021, 5:33 PM
minirkk
minirkk - avatar
+ 1
Thanks dude, I already solved this problem myself. About 9 minutes ago.
15th May 2021, 5:36 PM
Alexander Sokolov
Alexander Sokolov - avatar