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?
Asked
Active
Viewed 46 times
-1
-
6Attach the code :) – zdolny Nov 14 '18 at 00:21
-
1Share the code :) – A J Nov 14 '18 at 00:22
1 Answers
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