Script needs to be below ID's

Script needs to be below ID's

Following code will not work

  1. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> 

  2. <script type="text/javascript">
  3. $('#jQ').click(function() {
  4.   alert('Handler for .click() called.');
  5. });
  6. </script> 

  7. <input type="button" value="jQuery" id="jQ">
However this works

  1. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> 

  2. <input type="button" value="jQuery" id="jQ">

  3. <script type="text/javascript">
  4. $('#jQ').click(function() {
  5.   alert('Handler for .click() called.');
  6. });
  7. </script> 

I tried it on google chrome and firefox 3.6.13
Any fixes?