Why this JSFiddle does not work [duplicate]

2019-01-15 10:51发布

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?

1条回答
等我变得足够好
2楼-- · 2019-01-15 11:26

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

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

enter image description here

查看更多
登录 后发表回答