Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Thanked 0 Times in 0 Posts

    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>
    <script type ="text/javascript" src="jquery.js"></script>
    <script type ="text/javascript">
    alert("function called");
    alert("Thanks for visitng !");
    <a href="http://jquery.com/">jquery</a>

    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 03:34 PM.

  2. #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Thanked 330 Times in 326 Posts
    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?


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts