Adding embedded javascripts to html tags (e.g. onclick, onsubmit ... etc.) is considered bad practice.
<form id="form1" onsubmit="return validate();"> ... </form> <a id="link1" href="http://www.google.com/" onclick="return popup();">Link1</a>
But if we do this as shown below, is it possible that the validate or popup function will not be called because the user interacts with the page before calling the ready function?
<form id="form1"> ... </form> <a id="link1" href="http://www.google.com/">Link1</a> <script type="text/javascript"> $(document).ready( function(){ $('#form1').submit( </script>
source share