Reputation: 117
I've been trying to figure out why this isn't working for the past half hour. Apologies if I'm being an idiot, but i just can't seem to make it work!
Javascript:
function cancel(){
alert("working");
}
HTML:
<input type="button" onclick="cancel()" value="Cancel" />
http://jsfiddle.net/GaryP/Cg7yj/
Upvotes: 0
Views: 64
Reputation: 324790
When using JSFiddle, the "wrapping" options enclose your script in a function.
Functions defined in functions are only accessible to that particular function (like a variable declared with var
), and therefore cannot be accessed by the button.
Choose one of the "no wrap" options.
Upvotes: 3