Declare function inside the body tag leads to “Function not defined”

Couture

New Member
I render a java script function inside the body tag of my html. After the java script there is a button which calls this function which is declared by the \[code\]onclick\[/code\] attribute.\[code\]<script type="text/javascript"> function f(caller){ console.log('test'); }</script><button onclick="f(this)" type="button">A button</button>\[/code\]The problem is that it says "ReferenceError: f is not defined". What am I doing wrong?
 
Top