[Solved] Why is this JavaScript function not working when the code is correct?


Since continue is a reserved keyword in JavaScript, you can’t name your function that.

Instead, use a different name like such:

function doContinue() {
    var CM = document.getElementById("intro2");
    CM.style.display = (CM.style.display === 'block' ? 'none' : 'block');
}
#intro2 {
	display: none;
	text-align: center;
	color: black;
	position: absolute;
	left: 32%;
	bottom: 10%;
	width: 40%;
	height: 35%;
	border: none;
}
<button onclick="doContinue()" id="continue">Continue</button>

<div id="intro2">
  <p><h1>text text text text</h1></p>
  <a href="https://stackoverflow.com/questions/49904283/Page.html">Get started</a>
  <img src="https://placekitten.com/200/300"/>
</div>

2

solved Why is this JavaScript function not working when the code is correct?