jsFiddle: no connection between html and js? Can't call simple function from button?

Sorry if this is incredibly obvious, but I have no idea why this isn't working.

I'm trying to create a jsFiddle. However, I don't seem to be able to attach any of the javscript to any of the elements. For example, onclick is not calling my js function.

It doesn't get any simpler than this fiddle. I copy-pasted it from the W3 editor where it works just fine - click the button, get alert!

<button onclick="myFunction()">Click me</button>

function myFunction() {alert("sss");}

http://jsfiddle.net/tpip/NYkQN/2/

What am I missing here??


Solution 1:

Just change the way the JavaScript block is loaded to no wrap (head)

enter image description here

The standard setting here is that the JS is wrapped(!) to be run after the DOM has loaded. That means the function is not defined in global scope but inside the wrapper. Inline event handlers only work with globally defined functions though!

When setting to no wrap (head) the JS is loaded in the <head> and is not wrapped.