I'm starting with js and I have a doubt when it comes to printing text in the DOM with js.
I have a button that adds + 1
to var click
and I want that when the number of click reaches 5, it appears the text of the function sumar()
var click = 1;
document.getElementById("demo").innerHTML = click;
function sumar() {
click = click + 1;
document.getElementById("demo").innerHTML = click;
}
if (click > 5) {
function sumar() {
document.getElementById("demo2").innerHTML = "Es más que 5";
}
}
<h3 id="demo"></h3>
<h3 id="demo2"></h3>
<button id="button" onclick="sumar()">Click</button>