I want that the text ist hidden in the beginning and after clicking the button it is displayed. I would be really greatfull if someone would find the mistake in my code.
function F1()
{
var x = document.getElementById("step1DIV");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
<!DOCTYPE html>
<html>
<body>
<button onclick="F1()"> <b>Step 1</b> </button>
<div id="step1DIV">
<p> text </p>
</div>
</body>
</html>
style.displayis not available until it's set. I recommend having.hide{ display:none; }in CSS then haveElement.classList.add('hide')andElement.classList.remove('hide')orElement.classList.toggle('hide'). Unless you want to do a lot of typing, I generally recommend using CSS classes to style.