|
Basic jQuery doubt
hello all,
i am a noob when it comes to javascript and jquery. I have started learning jquery recently and was trying out some tutorials listed in the jquery site. While trying out the very first example i came across a very strange problem.
Here is the code :
<!doctype html>
<html>
<head>
<script type ="text/javascript" src="jquery.js"></script>
<script type ="text/javascript">
$(document).ready(function(){
alert("function called");
$("a").click(function(event){
alert("Thanks for visitng !");
});
});
</script>
</head>
<body>
<a href="http://jquery.com/">jquery</a>
</body>
</html>
The above code works absolutely fine. The problem is with line shown in green. As far my knowledge goes html tags which don;t have content in it can be closed as < tagname /> and thus i tried doing the same for the line mentioned in green.
<script type ="text/javascript" src="jquery.js" />
but to my surprise it didn't work in this case. Can you please let me explain me the reason behind this behavior.
Thanks !
Last edited by ianandg; 03-05-2010 at 02:34 PM..
|