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
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
in sveltekit your app would look like this:
<script>
function go() {
//stuff
}
</script>
<button type="button" id="okbutton" on:click={go}>OK</button>
are you deferring the scripts, like is the dom loading before the scripts or no
using an ordinary script tag in the <head>. I’m deferring the main script but that’s causing issues with some dependency scripts imported through unpkg