Answers for "Uncaught ReferenceError: function is not defined at HTMLUnknownElement.onclick"

1

Uncaught ReferenceError: function is not defined at HTMLUnknownElement.onclick

//Your program can't find the function so do this.

//You can assign the button onclick as an id.
//then attach an eventListener on run time like this:

<button id="btn">Click me!</button>

var btn = document.getElementById("btn");
btn.addEventListener("click", function() {
	//Do something here
}, false);
Posted by: Guest on September-23-2020

Code answers related to "Uncaught ReferenceError: function is not defined at HTMLUnknownElement.onclick"

Code answers related to "Javascript"

Browse Popular Code Answers by Language