Randomly Inserting Images Into Table Using Javascript
I'm very new to javascript and I'm creating a game where a user re-arranges a table of pictures by clicking. The images are really scrambled pieces of a larger image that the user
Solution 1:
Your code is running before the elements are available on the page.
Move the script to the bottom, just before the closing body-tag.
Solution 2:
put all your
document.getElementById("image1").src = diffImage();
inside a function and call that function in the body onload
function newFunction()
{
document.getElementById("image1").src = diffImage();
...
}
<body onload="addEventListeners(); newFunction();">
Post a Comment for "Randomly Inserting Images Into Table Using Javascript"