SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member m16guy's Avatar
    Join Date
    Feb 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery library issues for absolute beginner

    Hi

    I am completely new to jquery and javascript. I am trying to complete a basic alert action using jquery, but it doesn't seem to work. I want an alert box to pop on loading the webpage.

    I download jquery library 1.7.2 from the jquery website. When downloading my computer (running window 7) brings up a messages stating "the publsiher can not be verified" but yet the js file appears in my downloads folder (I am unable to open js file).

    I have written the follow code into notepad and saved it as a html.....

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>jquery test</title>

    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>

    <script type="text/javascript">

    $(document).ready(function() {
    alert("Jquery test 1-2-3");
    });
    </script>
    </head>

    <body>

    <h2>Test</h2>

    <p>This is the jquery alert</p>

    </body>
    </html>

    The webpage displays fine in IE, firefox etc... but the jquery action isn't working. Is the markup wrong?

    I also tried the google CDN link but still no joy.

    Any advise apprecited and thanks in advance

    ...

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,154
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    I used the code you posted and substituted in the google CDN link, and everything worked exactly as I expected, alert and all. So either the code you posted isn't the code you're actually running... or something is very messed up on your computer. I'm not sure I can be any more help than that at this point.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head>
    <title>jquery test</title>
    
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    
    <script type="text/javascript">
    
    $(document).ready(function() {
    alert("Jquery test 1-2-3");
    });
    </script>
    </head>
    
    <body>
    
    <h2>Test</h2>
    
    <p>This is the jquery alert</p>
    
    </body>
    </html>

  3. #3
    SitePoint Member m16guy's Avatar
    Join Date
    Feb 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow!!! it worked I must have been inserting the wrong google CDN link!

    Thanks alot, your assistants is much appreciated


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
  •