Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74074

How to fix this error in HTML (no error shown)

$
0
0

My function createBomb() is not working because none of the elements are turning into bombs.

I've tried finding the error.

HTML:

<div class = "grid-square" onclick = "check(1,8)" id = "18">?</div>

Javascript:

function createBomb() {
    bombNum = Math.floor(Math.random() * 80) + 1;
    if (!document.getElementById(bombNum).classList.contains("bomb")) {
        document.getElementById(bombNum).classList.add("bomb");
    } else {
        createBomb();
    }
}
createBomb();

I expect the function createBomb() to make a random div a bomb.


Viewing all articles
Browse latest Browse all 74074

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>