Sunday, June 23, 2019

javascript dosnt seem to be working




im trying to build a minesweeper in html and the javascript isnt woking



heres my html



    



href = "minesweeper.css" >









here is the css



td{
border: 2px outset #000000;
width:25px;
height: 25px;
background-color: #cfcfcf;
}



and here is the javascript (minesweeper.js)



   var gameBox = document.getElementById("i").innerHTML;
console.log(gameBox);
for ( var i = 0 ; i < 3 ; i++ ) {

gameBox += "";
console.log(gameBox);
for ( var j = 0 ; j < 3 ; j++ ) {
gameBox += "";

}
gameBox += "";
}


and all i get is a blank page



heres a link to the page
http://borisute.com/geshem/2013/mkeller/minsweeper.html
(it has some more code i didnt include b/c its not relevant to the above problem



Answer



You still need to put the gamebox onside the html at the end of the script:



var gameBox = document.getElementById("i").innerHTML;
for ( var i = 0 ; i < 3 ; i++ ) {

gameBox += "";
for ( var j = 0 ; j < 3 ; j++ ) {
gameBox += "";
}

gameBox += "";
console.log(gameBox);
}
document.getElementById("i").innerHTML = gameBox;

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...