I know this is probably something really dumb, but it really pisses me off for a good 15 minutes. What am I missing here?
<input type="button" value="Go" onclick="showAlert()">
function showAlert() {
alert('???');
}
I know this is probably something really dumb, but it really pisses me off for a good 15 minutes. What am I missing here?
<input type="button" value="Go" onclick="showAlert()">
function showAlert() {
alert('???');
}
Because in that fiddle you've chosen to define the function "onLoad".
That's same as defining it in window.onload=function(){...}
, which makes it unaccessible outside the onload
scope (i.e. you can call it only from that onload
), as happens with any nested functions.
You should define that function in the <head>
, choose the third option.