Search code examples
javascriptfile-not-found

javascript not loading image error::ERR_FILE_NOT_FOUND


Hey guys i am building dice roller website using random in javascript but after setting attributes for dice image i am getting file not found error.Images are stored like images/dice.png

enter image description here

ack.imgur.com/TBRUD.png


Solution

  • your actualy seting the image's source to the str randomImg rather then the variable's value what you want to do is remove the "" that make it a string and use the variable so the last line of the js would look like document.querySelectorAll[0].setAttribute('src',randomImg)