theglasspenguin @theglasspenguin

ok i need help again with my code

so this is my current setup:

HTML:

<button type="button" id="okbutton" onclick="go()">OK</button>

JS:

function go() {
// stuff
}

every time i’ve clicked the button, nothing happens and i get "go()" is not defined in the console

Nov 20, 2022, 1:52 AM
11
View all

comments

Highlighted comment

definition needs be before button

<script>
function go() {...}
</script>
<button ... />

or you can just do

document.querySelector("#okbutton").addEventListener("click", (event) => {...});

i have the script imported from a tag in the <head>, so i would imagine it is before the button