Javascript examples for jQuery:Document
Define functions in jQuery's document.ready()
<html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> <script> var foo; // Here's the difference $(document).ready(function(){ foo = function ()// w ww. j a v a 2 s. c o m { console.log('Bar'); } }); </script> </head> <body> <input type="button" onclick="foo()" value="Click me"> </body> </html>