javascript - jquery not working inside html file -
i'm trying basic jquery tutorial i'm not able work. i'm calling jquery library google , try create script inside html.
if same in .js file wouldn't have problem. missing here?
<html> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> </head> <body> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"> $(document).ready(function() { $("a").click(function() { alert("hello world!"); }); }); </script> <a href="">link</a> </body> </html>
you need split up:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"> $(document).ready(function() { $("a").click(function() { alert("hello world!"); }); }); </script>
...into 2 script elements:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("a").click(function() { alert("hello world!"); }); }); </script>
in snippet gave, code within <script>
element won't evaluated because browser evaluating contents src
attribute , ignoring else.
Comments
Post a Comment