1

Beginner here, go easy on me, I have a simple problem, but I keep getting errors. My code is very simple, all I want is for this button to invert my bool so that different content can pull from that bools state to change certain content on the fly. However, when the button is actually clicked I get this error in the console:

"Uncaught ReferenceError: Br1c1 is not defined at HTMLButtonElement.onclick (File.html:32)"

line 32 is the line where my button is defined.

All I want is the button to invert my bool function.

<script>
   boolean Br1c1 = "true";
</script>

<button class="button" id="r1c1" onclick="return Br1c1 = !Br1c1;"></button>
1
  • 2
    There's no data types in javascript. Instead of boolean use var Br1c1 = true; Commented Apr 22, 2019 at 19:25

2 Answers 2

1

Try

var Br1c1 = "true";
<button class="button" id="r1c1" onclick="Br1c1 = !Br1c1; return true;"></button>
Sign up to request clarification or add additional context in comments.

Comments

0

You only need to change boolean by var like that:

var Br1c1 = "true";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.