Flash
Flash

Reputation: 16723

jsFiddle - what am I missing?

Quick question for people familiar with 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.

Upvotes: 0

Views: 281

Answers (3)

Arun P Johny
Arun P Johny

Reputation: 388346

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
    }
}

Upvotes: 1

mu is too short
mu is too short

Reputation: 434695

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/

Upvotes: 3

Steve Wellens
Steve Wellens

Reputation: 20640

Under Framework select "no wrap (head)

Click the Run button.

It should now work.

Upvotes: 1

Related Questions