JavaScript function/onclick not working

<h4 id="myH4">?????</h4>
<button id="myButton" onclick="myButton">Click Here!</button>
document.getElementById("#myButton").onclick = function(){
	const h4 = document.getElementById("#myH4");
	h4.innerText = "$59,343";

Explain what is not working. What are you wanting this code to do that it is not?

You are not providing the correct id name to document.getElementById,

I’m trying to change style of an element, and it’s not functioning

What part of the code is attempting to change the style of an element?

By my guess, everything inside the curly braces.

Go to the link I posted and look at the examples.

1 Like