开发者

jsFiddle - what am I missing?

开发者 https://www.devze.com 2023-03-01 04:17 出处:网络
Quick question for people familiar wi开发者_如何转开发th jsFiddle: why doesn\'t this run the function when the button is clicked?

Quick question for people familiar wi开发者_如何转开发th jsFiddle: why doesn't this run the function when the button is clicked?

I'm sure I'm missing something obvious, but can't get it working.


You need to select the "no wrap (head)" option in the sidebar. Otherwise, your f() function gets wrapped up in some $(function() { /*...*/ }); stuff and is not visible to be set in an onclick attribute:

http://jsfiddle.net/ambiguous/a6rQX/


Under Framework select "no wrap (head)

Click the Run button.

It should now work.


It is because the function with name f() local to the onReady function, so it is not available in the global context.

onReady(){
    function f(){
        xyz
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消