Why isn't the javascript onclick function called?
问题 I have created a JSFiddle to describe the issue. Why isn't the alert displayed when I call the doSomething() function? 回答1: You need to disable framework option in jsfiddle for javascript to work DEMO function doSomething() { alert('Hello!'); } 回答2: This is because doSomething() function is not defined in the HTML page. In jsfiddle your function (in js pane) is wrapped by document onload event of jquery. (see at the left side of jsfiddle for settings). So Its executed like this, $(document)