jquery - Button click handler is not working -


i have code. can tell me missing? in advance.

 <!doctype>     <html>     <head>     <script="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js">     </script>     </head>     <body>     <button id="button1">addrow</button>             <script>            $(document).ready(function(){                $('#button1').click(function(){                        alert("button1 clicked");                });             });         </script>     </body>     </html> 

error line:

<script="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"> </script> 

your script tag not formed. result jquery not loaded , error

uncaught referenceerror: $ not defined

solution: add space after script , use type before ="text/javascript",

<!doctype>      <html>      <head>      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js">      </script>      </head>      <body>      <button id="button1">addrow</button>              <script>             $(document).ready(function(){                 $('#button1').click(function(){                         alert("button1 clicked");                 });              });          </script>      </body>      </html>


Comments