Search code examples
javascriptjsfiddle

Why this JSFiddle does not work


I have written a simple function:

function clickedMe() {
  alert(this + " : " + this.tagName + " : " + this.id);
}

And I am calling it on click event of button element

<button onclick="clickedMe()">button</button>

This works when I created a standalone HTML page locally. However it does not seem to work on JSFiddle. Here is the link: http://jsfiddle.net/Mahesha999/fACce/

Whats wrong here?


Solution

  • Select no wrap - in <head>/<body> .

    It doesn't work because clickedMe is not in the global scope.

    enter image description here