SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Sep 2012
    Location
    Croydon NSW Australia
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery beginner:Help please?

    Im brand new to Javascript and Jquery. BRAND new. Ive been through this basic tutorial and downloaded the latest version of Jquery (jquery-1.10.2.js), Im not getting a dialogue window on launch from a basic HTML window. I hope Im pointing correctly to the .js file in my directory.

    The tutorial link if needed is http://learn.jquery.com/about-jquery/how-jquery-works/

    Can anyone please tell me what Im doing wrong? Many thanks for any contributions.

    Code below:

    Code:
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title>Demo</title>
    </head>
    <body>
    <a href="http://jquery.com/">jQuery</a>
    <script src="jquery-1.10.2.js"></script>
    <script>
    // Your code goes here.
    </script>
    </body>
    </html>
    Last edited by Force Flow; Sep 12, 2013 at 18:11. Reason: added code tags

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You should have some code where it says:

    // Your code goes here.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member
    Join Date
    Sep 2012
    Location
    Croydon NSW Australia
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS

    Sorry, I pasted the wrong version as my example. This is where Im at..still no message on screen.


    <!doctype html>
    <html>
    <head>

    <script type="text/javascript" src"../jquery-1.3.1.min.js"></script>
    <script type="text/javascript">
    $ ("document") .ready (function () {
    alert ("the page just loaded!");
    });
    </script>
    </head>
    <body>
    <h1 id="hello-world">Hello World</h1>

    </body>
    </html>

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Hi RaveyDavey,

    If you're new to JavaScript then jQuery isn't a good starting point as you need a good knowledge of writing vanilla JS before using a library such as jQuery, there are lots of great places to learn JavaScript such as the following.

    https://learnable.com/books/simply-javascript
    https://learnable.com/courses/javasc...for-the-web-40

    Once you've got a good understanding of writing vanilla JS code then you can move onto using more advanced libraries such as jQuery.

    https://learnable.com/courses/jquery-fundamentals-1132
    https://learnable.com/books/jquery-novice-to-ninja
    https://learnable.com/books/jquery-n...cks-and-tricks

  5. #5
    SitePoint Member
    Join Date
    Sep 2012
    Location
    Croydon NSW Australia
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much...I appreciate the pointers.

  6. #6
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,938
    Mentioned
    214 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    First off, I agree with what Chris said in post #4.
    However, to address your problem here, I would check your path to jQuery, as the code you provided is otherwise fine.

    A couple of tips.

    If you put your scripts just before the closing body tag, you almost never have to test if the DOM is ready, because it is by definition:

    Code:
    <!DOCTYPE HTML>
    <html>
      <head>
        <meta charset="utf-8">
        <title>Test</title>
      </head>
      
      <body>
        <h1 id="hello-world">Hello World</h1>
        
        <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
        <script type="text/javascript">
          alert("the page just loaded!");
        </script>
      </body>
    </html>
    If you aren't doing anything with jQuery, you don't need to include it:

    Code:
    <!DOCTYPE HTML>
    <html>
      <head>
        <meta charset="utf-8">
        <title>Test</title>
      </head>
      
      <body>
        <h1 id="hello-world">Hello World</h1>
        
        <script type="text/javascript">
          alert("the page just loaded!");
        </script>
      </body>
    </html>
    Don't get put off if this all seems a bit daunting. Everyone has to start somewhere.
    Feel free to let us know if you have any more questions.


Bookmarks

Posting Permissions

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