RocketNuts
RocketNuts

Reputation: 11120

JavaScript function not found on jsfiddle

Very simple minimal jsfiddle example:

https://jsfiddle.net/a9f2j4xo/

Clicking the button should invoke the Bla() function.

When I click the button the console says

ReferenceError: Bla is not defined.

Who or what is malfunctioning here, jsfiddle or my brain?

Upvotes: 4

Views: 1628

Answers (2)

HimanshuArora9419
HimanshuArora9419

Reputation: 737

This seems to be something weird. Because on putting it inside script tag it is working. See js fiddle here https://jsfiddle.net/a9f2j4xo/

<button onclick='Bla()'>
Test
</button>
<script>
function Bla()
{
    alert('yes'); 
}
</script>

Upvotes: 0

Sajeetharan
Sajeetharan

Reputation: 222552

You need to wrap the function script inside <head> . Otherwise your script is not invoked.

Change the settings as

LOAD TYPE - Wrap in <Head>

WORKING DEMO

enter image description here

Upvotes: 13

Related Questions