0

It's very basic, but it's not working. I know I must be missing something really obvious.

Here is the fiddle.

http://jsfiddle.net/NWWL4/

<input type="button" onclick='clicked();' value='Click Me!'></input>

function clicked() {
    alert('test');
}
  • 1
    exact duplicate of [Simple example doesn't work on JSFiddle](http://stackoverflow.com/questions/5431351/simple-example-doesnt-work-on-jsfiddle) – Bergi Jun 12 '13 at 19:22
  • JS inline code doesn't work in JSFiddle. Also, you shouldn't use it. Declare the function as global if you want use it like this, but it is not proper : http://jsfiddle.net/NWWL4/4/ – sdespont Jun 12 '13 at 19:24

2 Answers2

5

You have your fiddle executing the JavaScript onload instead of in the head of the document.

j08691
  • 204,283
  • 31
  • 260
  • 272
1

try changing

function clicked() {
    alert('test');
}

to

clicked = function() {
    alert('test');
}
Peter Berg
  • 6,006
  • 8
  • 37
  • 51