+ 1
Why does my function keep crashing the page?
I'm new to javascript and I can't figure out why my page keeps crashing when I run this function: function q1check() { var x= document.getElementById("q1form").value; if (x=="V") {var correct = document.getElementById("q1ans").innerHTML = "✅";} else {var incorrect = document.getElementById("q1ans").innerHTML = "❌"; var inccom = document.getElementById("q1comm").innerHTML = "Check Section 2"} } It will give the desired output and then crash the page. Any help would be greatly appreciated.
2 Answers
+ 5
I can't find any errors besides this one: the variable x will not ever = "V". You should use .innerHTML instead.
0
The problem was on the html side. Was using a form instead of a simple input. It made the input dissapear almost as soon as it was submitted