javascript - jQuery click not fired -
i have simple html file little bit of jquery in click event not triggered here:
i not getting error , neither console.log statement expect print when click event triggered. did miss out on something?
<!doctype html> <html> <head> <title>my webpage</title> <link rel="stylesheet" type="text/css" href="day.css"/> <link rel="stylesheet" type="text/css" href="night.css"/> </head> <body> <h1> website </h1> <button>day</button> <button>night</button> <script src="jquery.js"/> <script> (function(){ console.log('inside func'); $('button').click(function() { console.log('button clicked'); }); })(); </script> </body> </html>
<script src="jquery.js"/>
should become:
<script src="jquery.js"></script>
you can read more self-closing script tags here: why don't self-closing script tags work?
Comments
Post a Comment