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

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.

Leave a Comment