Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-05-2010, 02:30 PM   PM User | #1
ianandg
New to the CF scene

 
Join Date: Mar 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ianandg is an unknown quantity at this point
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..
ianandg is offline   Reply With Quote
Old 03-05-2010, 03:10 PM   PM User | #2
tomws
Senior Coder

 
tomws's Avatar
 
Join Date: Nov 2007
Location: Arkansas
Posts: 2,644
Thanks: 29
Thanked 330 Times in 326 Posts
tomws will become famous soon enoughtomws will become famous soon enough
Because script tags are required to have separate open and close tags. Maybe someone else has a more intellectual response. All I know is that they only work that way.
__________________
Are you a Help Vampire?
tomws is offline   Reply With Quote
Reply

Bookmarks

Tags
basic, closing tags, jquery

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:29 AM.


Advertisement
Log in to turn off these ads.