help Why doesn't this work (new to javascript)
Go to solution
Solved by Instillingererno,
2 minutes ago, Minibois said:Can you put something like "alert("It should work);" inside the if statement? If that comes up on your screen when you press the button, you know the problem lies within the text changing part. If not, it doesn't even go into that if statement.
3 minutes ago, Mr_KoKa said:
<html> <head> <title>Eksempel_2</title> <meta charset="utf-8" /> <script> var Tekst = false; function btnUtfor_onclick() { if (Tekst == false) { document.getElementById("pMelding").innerText = "DerpDerp"; } else { document.getElementById("pMelding").innerText = ""; } Tekst = !Tekst; } </script> </head> <body> <input id="btnUtfor" type="button" value="Trykk meg" onclick="btnUtfor_onclick()" /> <p id="pMelding"></p> </body> </html>
Now it works, seems there was something with the boolean? Thank you!

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now