SyntaxFix
Write A Post
Hire A Developer
Questions
This code seems to work fine (see this jsfiddle). Is your javascript defined before your body? When the browser reads onclick="myFunction()" it has to know what myFunction is.
onclick="myFunction()"
myFunction