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??
With JSFiddle, you can write code in the JavaScript box and then execute it by clicking the Run button on the menu bar at the top of the JSFiddle page.
In the very own, for example, http://jsfiddle.net/Ua8Cv , if you just type the extra /show at the address bar and hit enter (followed by the browser show source code shortcut) to get the source.
JSFiddle is an online IDE service and online community for testing and showcasing user-created and collaborational HTML, CSS and JavaScript code snippets, known as 'fiddles'. It allows for simulated AJAX calls.
Just change the way the JavaScript block is loaded to no wrap (head)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With