-1

I declare my function in javascript, but when I execute the code it appears “function javascript not defined”, does anyone know how to solve it?

Martin Heralecký
  • 5,649
  • 3
  • 27
  • 65

1 Answers1

0

function test(){
  alert('Test')
}

var btn = document.getElementById('testButton');
btn.addEventListener("click", test);
html { font-family: Helvetica, Arial, sans-serif; }
body { padding: 20px }
<html>
<p>Here is a generic example of using a JavaScript function in HTML.</p>
<button id="testButton">Test</button>
</html>
Harvey A. Ramer
  • 763
  • 7
  • 13