+ 1
Why this dosen’t works
<button onclick="Func1" id="Boton1"></button> function Func1() { var Cuadrado1 = document.getElementById("Boton1"); if(Cuadrado1).pressed { alert("Hola"); }
1 Antwort
+ 2
In your button onClick you need parenthesis. onclick="Func1()"
In your function Func1, you don't need the if(Cuadrado1).pressed { because that's what the onclick does, fires when clicked.
<button onclick="Func1()" id="Boton1"></button>
function Func1() {
alert("Hola");
}