Announcement

Collapse
No announcement yet.

trying to install and get jQuery to work...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • trying to install and get jQuery to work...

    I want to play around with some jQuery, but I can't get anything to work. I must be missing something somewhere...I posted my test page below. When I click the link it should fade the red box out, but nothing happens. I don't get any errors in Firebug and I know my path to the javascript file is correct. Any ideas?

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta name="subject" content="" />
    <meta name="Description" content="" />
    <meta name="Keywords" content="" />
    <title></title>
    <link href="xxx.css" rel="stylesheet" type="text/css" media="screen"/>
    <link rel="icon" href="favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <script src="http://www.site.com/js/jquery-1.3.2.min.js" type="text/javascript"></script>

    <style type="text/css">

    #box {background-color: red; width: 300px; height: 300px;}

    </style>

    <script type="text/javascript">
    $(function() {
    $('a').click(function() {
    $('#box').fadeOut();
    });
    });

    </script>


    </head>

    <body>

    <div id="box">

    </div>
    <a href="">fade Out</a>

    </body>

    </html>

  • #2
    haha wow, find out the problem....I added a "#" into the link href and it worked...

    <div id="box">

    </div>
    <a href="#">fade Out</a>

    Comment


    • #3
      Two quick things:
      1)You should link to jQuery like this:
      Code:
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      That way it's possible the user will have it cached.

      2) you should add return false to the end of any link function that doesn't activate a link
      Code:
      $('a').click(function() {
      $('#box').fadeOut();
      return false;
      });
      This makes sure that the link is not activated by the browser.
      Swedish Meatball Pornography

      Comment

      Search

      Collapse

      Sponsor

      Collapse

      Incredible Stock

      Latest Topics

      Collapse

      • iyiyi
        Your Favorite Graphic Design Book
        iyiyi
        I know this can span a wide variety of topics, but I'm curious what your favorite design book is.
        My focus is branding and logo design, but trying to build a library of design books.

        ...
        Yesterday, 09:08 PM
      • PrintDriver
        Comment on I am feeling frustrated in my job search?
        PrintDriver
        The point at which no one is able to make a living in a once thriving profession. Your ''secondary skill'' definition would be that cliff.
        Yesterday, 06:45 PM
      • PrintDriver
        Reply to Exhibit text, large format
        PrintDriver
        There is no ''general rule''

        The idea is not to have rivers running through it. Sometimes you have to suggest to the client that they might have to change a word here and there (as long as...
        Yesterday, 06:38 PM
      • designzombie
        Comment on I am feeling frustrated in my job search?
        designzombie
        I predict that the worse case scenario is graphic design reduced to secondary skill status.

        What is ''the cliff?''
        Yesterday, 05:43 PM
      • KitchWitch
        Reply to Exhibit text, large format
        KitchWitch
        Hi Moniker and welcome to GDF.

        We ask all new members to read very important links here and here. These explain the rules, how the forum runs and a few inside jokes. No, you haven't done...
        Yesterday, 03:30 PM
      GDF A division of Mediabistro Holdings Adweek | Mediabistro | Clio | Film Expo Group Contact Us | Terms of Use | Privacy Policy Copyright 2016 Mediabistro Holdings
      Working...
      X