treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[SOLVED] jQuery not working at all!

  • Hi,

    I'm just starting to learn jQuery actually.. I downloaded the starterkit, unpacked it and also downloaded the latest jQuery file from jquery.com.. all referenced to with the right path in the file but for some reason it doesn't work! I also tried the link to the jQuery file on Google but still the same problem.. I know the path is right because when I view source and click on the link, the right file opens.

    If I click the 'Run Code' button on the homepage of jQuery.com it does what it's supposed to do, just on my own computer nothing works?! I tried different browsers but that doesnt help either.

    Any ideas?
  • Post your source code?

    Or, uses your browsers debugging tools and view the console. It'll tell you what's causing the error
  • The code is too long to post, but it's just the starterkit file taken directly from http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery. And the jquery.js file I link to is just the jQuery file I downloaded from jQuery.com - I don't suppose I should post that here either.

    I tried using the console but no errors showed up.
  • Well without the source code we'll just be guessing... Doesn't matter how long it is, there is very little we can do to help without the code. Can you post your source code along with what you expect it to be doing.

    Cheers
  • First part:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    <html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>jQuery Starterkit</title>

    <link rel="stylesheet" type="text/css" media="screen" href="screen.css" />
    <script src="jquery.js" type="text/javascript"></script>
    <script src="custom.js" type="text/javascript"></script>

    </head>
    <body>
    <h1>jQuery Starterkit</h1>
    <h2>This page contains code to test the examples. Most of it is only relevant for a example.</h2>

    <a id="first" href="#">Some link</a>

    <div class="stuff">

    <a name="top" href="#bottom">Go to bottom</a>

    <div class="buttons">
    <button>First button</button>
    <button>Second button</button>
    </div>

    <ol id="orderedlist">
    <li>First element</li>
    <li>Second element</li>
    <li>Third element</li>
    </ol>

    <ol id="orderedlist2">
    <li>First element, second list</li>
    <li>Second element, second list</li>
    <li>Third element, second list</li>
    <li>Li with child ul
    <ul>
    <li>Child One</li>
    <li>child two</li>
    </ul>
    </li>
    </ol>

    <div id="rating">Container</div>

    <a id="reset" href="#">Reset!</a>

    <form id="form">
    Form 1
    <input value="XXX" />
    <input />
    </form>

    <form>
    Form 2
    <input value="YYY" />
    <input />
    </form>

    <form>
    Form 3
    <input type="checkbox" />
    <input type="checkbox" checked="checked" />
    </form>

    <h3>Bird FAQ - click the questions to show the answers</h3>
    <dl id="faq">
    <dt>What shouldn't I do to the bird?</dt>
    <dd>Never use oils or lotions which contain oils on your bird. They gunk up the feathers,
    and ruin their insulating properties. This means a chilled bird. Never wait out a cat bite--those
    require immediate veterinary attention--a bird can die within two days because a cat's mouth is so
    filthy and full of bacteria. Don't bother with over-the-counter medication. It really doesn't work,
    and in some cases, may upset the delicate bacterial balance in the bird's body, or even worsen the
    situation. Never try to treat a fracture at home.</dd>

    <dt>My bird is healthy. I don't need to go to a vet, do I?</dt>
    <dd>Schedule a "well-bird" checkup. Prevention is the best medicine. Even though the bird might appear outwardly healthy, it may have a low-grade infection or something not so readily apparent. Your bird's health and your peace of mind will be worth it.</dd>

    <dt>My bird's leg is being rubbed raw by the leg band. Can I take it off?</dt>
    <dd>No. Don't attempt this, especially if the leg is broken or swollen. The vet will be able
    to remove the band, and deal with whatever injury maybe lurking under the banded area.</dd>

    <dt>How do I pull a broken blood feather?</dt>
    <dd>This is probably the most common mishap. The remedy is simple--yank! It's most easily done
    with two people. One to restrain the bird and the other to pull the feather. Use pliers, or a
    hemostat. Tweezers won't work on primaries. Make certain that the wing bones are firmly supported
    or you can break the wing. Clamp onto the feather and give a sharp tug in the direction of the
    feather. The feather will come out. Next, apply gentle, direct pressure to the follicle where the
    feather was to stop the bleeding. Dab some styptic powder on it, as it will help stop the bleeding
    as well. Let the bird rest. Ask your vet or breeder to demonstrate exactly how to pull a blood
    feather if you're apprehensive about doing it.</dd>
    </dl>

    <p>This is probably the most common mishap. The remedy is simple--yank! It's most easily done
    with two people. One to restrain the bird and the <a href="#"> This is a link. Hover me to
    highlight the parent paragraph.</a> other to pull the feather. Use pliers, or a hemostat. Tweezers won't
    work on primaries. Make certain that the wing bones are firmly supported or you can break the wing.
    Clamp onto the feather and give a sharp tug in the direction of the feather. The feather will come
    out. Next, apply gentle, direct pressure to the follicle where the feather was to stop the bleeding.
    Dab some styptic powder on it, as it will help stop the bleeding as well. Let the bird rest. Ask
    your vet or breeder to demonstrate exactly how to pull a blood feather if you're apprehensive about
    doing it.</p>

    <p>This is probably the most common mishap. The remedy is simple--yank! It's most easily done
    with two people. One to restrain the bird and the <a href="#"> This is a link. Hover me to
    highlight the parent paragraph.</a> other to pull the feather. Use pliers, or a hemostat. Tweezers won't
    work on primaries. Make certain that the wing bones are firmly supported or you can break the wing.
    Clamp onto the feather and give a sharp tug in the direction of the feather. The feather will come
    out. Next, apply gentle, direct pressure to the follicle where the feather was to stop the bleeding.
    Dab some styptic powder on it, as it will help stop the bleeding as well. Let the bird rest. Ask
    your vet or breeder to demonstrate exactly how to pull a blood feather if you're apprehensive about
    doing it.</p>
  • Second part:
    <h1>jQuery Tablekit</h1>

    <!-- tablecode taken from tablesorter examples -->

    <table id="large" cellspacing="0">
    <thead>

    <tr>
    <th>Email</th>
    <th>Id</th>
    <th>Phone</th>
    <th>Total</th>
    <th>Ip</th>

    <th>Url</th>
    <th>Time</th>
    <th>ISO Date</th>
    <th>UK Date</th>
    </tr>
    </thead>
    <tbody>
    <tr>

    <td>devo@flexomat.com</td>
    <td>66672</td>
    <td>941-964-8535</td>
    <td>$2482.79</td>
    <td>172.78.200.124</td>

    <td>http://gmail.com</td&gt;

    <td>15:10</td>
    <td>1988/12/14</td>
    <td>14/12/1988</td>
    </tr>

    <tr>
    <td>henry@mountdev.net</td>

    <td>35889</td>
    <td>941-964-9543</td>
    <td>$2776.09</td>
    <td>119.232.182.142</td>
    <td>http://www.gmail.com</td&gt;
    <td>3:54</td>

    <td>1974/1/19</td>
    <td>19/1/1974</td>
    </tr>

    <tr>
    <td>christian@reno.gov</td>
    <td>60021</td>

    <td>941-964-5617</td>

    <td>$2743.41</td>
    <td>167.209.64.181</td>
    <td>http://www.dotnet.ca</td&gt;
    <td>10:58</td>
    <td>2000/3/25</td>

    <td>25/3/2000</td>

    </tr>

    <tr>
    <td>muffins@donuts.com</td>
    <td>17927</td>
    <td>941-964-9511</td>

    <td>$2998.18</td>
    <td>210.214.231.182</td>

    <td>http://google.se</td&gt;
    <td>21:22</td>
    <td>1993/1/24</td>
    <td>24/1/1993</td>

    </tr>

    <tr>
    <td>muffins@reno.gov</td>

    <td>76375</td>
    <td>941-964-2757</td>
    <td>$1836.09</td>

    <td>220.222.93.171</td>
    <td>http://www.samba.org</td&gt;
    <td>15:22</td>

    <td>1988/4/4</td>
    <td>4/4/1988</td>
    </tr>


    <tr>
    <td>mendez@gmail.com</td>
    <td>45834</td>
    <td>941-964-2575</td>

    <td>$2805.46</td>
    <td>228.170.245.253</td>

    <td>http://flexomat.com</td&gt;
    <td>11:31</td>
    <td>1975/12/12</td>
    <td>12/12/1975</td>

    </tr>

    <tr>

    <td>dev@gmail.com</td>
    <td>20022</td>
    <td>941-964-4967</td>
    <td>$3296.54</td>
    <td>175.248.70.240</td>

    <td>http://www.flexomat.com</td&gt;

    <td>4:27</td>
    <td>2002/7/3</td>
    <td>3/7/2002</td>
    </tr>

    <tr>
    <td>foo@polyester.se</td>

    <td>55977</td>
    <td>941-964-745</td>
    <td>$2953.73</td>
    <td>222.114.227.156</td>
    <td>http://www.donuts.com</td&gt;
    <td>23:49</td>

    <td>1977/8/4</td>
    <td>4/8/1977</td>
    </tr>

    <tr>
    <td>adam@aftonbladet.se</td>
    <td>38867</td>

    <td>941-964-6302</td>

    <td>$1949.27</td>
    <td>116.241.143.196</td>
    <td>http://flexomat.com</td&gt;
    <td>23:35</td>
    <td>1995/7/27</td>

    <td>27/7/1995</td>

    </tr>

    <tr>
    <td>devo@donuts.com</td>
    <td>51426</td>
    <td>941-964-1234</td>

    <td>$1067.00</td>
    <td>88.96.149.82</td>

    <td>http://www.polyester.se</td&gt;
    <td>15:17</td>
    <td>1986/1/5</td>
    <td>5/1/1986</td>

    </tr>

    <tr>
    <td>henry@samba.org</td>

    <td>40859</td>
    <td>941-964-4856</td>
    <td>$3401.19</td>

    <td>68.152.250.74</td>
    <td>http://www.flexomat.com</td&gt;
    <td>4:36</td>

    <td>1990/3/7</td>
    <td>7/3/1990</td>
    </tr>


    <tr>
    <td>found@dotnet.ca</td>
    <td>23986</td>
    <td>941-964-2686</td>

    <td>$1393.52</td>
    <td>98.102.181.138</td>

    <td>http://lostnfound.org</td&gt;
    <td>5:51</td>
    <td>1993/7/22</td>
    <td>22/7/1993</td>

    </tr>

    <tr>

    <td>carl@fish.org</td>
    <td>73392</td>
    <td>941-964-5792</td>
    <td>$3876.04</td>
    <td>246.234.182.243</td>

    <td>http://www.google.se</td&gt;

    <td>6:52</td>
    <td>1984/7/14</td>
    <td>14/7/1984</td>
    </tr>

    <tr>
    <td>found@mountdev.net</td>

    <td>03519</td>
    <td>941-964-1599</td>
    <td>$1176.48</td>
    <td>104.212.122.177</td>
    <td>http://donuts.com</td&gt;
    <td>18:52</td>

    <td>2000/8/6</td>
    <td>6/8/2000</td>
    </tr>

    <tr>
    <td>lost@fish.org</td>
    <td>36628</td>

    <td>941-964-5975</td>

    <td>$822.23</td>
    <td>153.63.68.208</td>
    <td>http://www.gmail.com</td&gt;
    <td>7:53</td>
    <td>1994/7/14</td>

    <td>14/7/1994</td>

    </tr>

    <tr>
    <td>mendez@dotnet.ca</td>
    <td>90442</td>
    <td>941-964-1649</td>

    <td>$1975.72</td>
    <td>128.161.95.170</td>

    <td>http://reno.gov</td&gt;
    <td>8:35</td>
    <td>1997/10/20</td>
    <td>20/10/1997</td>

    </tr>

    <tr>
    <td>carl@donuts.com</td>

    <td>00412</td>
    <td>941-964-6432</td>
    <td>$1834.77</td>

    <td>141.231.126.192</td>
    <td>http://gmail.com</td&gt;
    <td>16:15</td>

    <td>1997/8/23</td>
    <td>23/8/1997</td>
    </tr>


    <tr>
    <td>foo@fish.org</td>
    <td>80653</td>
    <td>941-964-1022</td>

    <td>$260.26</td>
    <td>98.102.97.81</td>

    <td>http://samba.org</td&gt;
    <td>8:27</td>
    <td>1991/11/24</td>
    <td>24/11/1991</td>

    </tr>

    <tr>

    <td>found@fish.org</td>
    <td>54635</td>
    <td>941-964-6439</td>
    <td>$1442.80</td>
    <td>108.133.231.154</td>

    <td>http://dotnet.ca</td&gt;

    <td>6:47</td>
    <td>1977/7/12</td>
    <td>12/7/1977</td>
    </tr>

    <tr>
    <td>found@flexomat.com</td>

    <td>20953</td>
    <td>941-964-5544</td>
    <td>$575.42</td>
    <td>247.246.235.138</td>
    <td>http://gmail.com</td&gt;
    <td>3:12</td>

    <td>1978/6/10</td>
    <td>10/6/1978</td>
    </tr>

    <tr>
    <td>lost@aftonbladet.se</td>
    <td>60810</td>

    <td>941-964-8406</td>

    <td>$1054.39</td>
    <td>130.80.125.154</td>
    <td>http://www.samba.org</td&gt;
    <td>15:50</td>
    <td>1978/5/18</td>

    <td>18/5/1978</td>

    </tr>

    <tr>
    <td>carl@reno.gov</td>
    <td>22666</td>
    <td>941-964-104</td>

    <td>$373.59</td>
    <td>185.150.127.115</td>

    <td>http://www.lostnfound.org</td&gt;
    <td>10:11</td>
    <td>1971/11/5</td>
    <td>5/11/1971</td>

    </tr>

    <tr>
    <td>carl@donuts.com</td>

    <td>82867</td>
    <td>941-964-1031</td>
    <td>$631.03</td>

    <td>62.244.222.152</td>
    <td>http://www.reno.gov</td&gt;
    <td>11:24</td>

    <td>1985/1/22</td>
    <td>22/1/1985</td>
    </tr>


    <tr>
    <td>foo@donuts.com</td>
    <td>11268</td>
    <td>941-964-208</td>

    <td>$3730.64</td>
    <td>234.192.138.252</td>

    <td>http://aftonbladet.se</td&gt;
    <td>22:45</td>
    <td>1979/8/4</td>
    <td>4/8/1979</td>

    </tr>

    <tr>

    <td>devo@google.se</td>
    <td>17059</td>
    <td>941-964-2903</td>
    <td>$1404.67</td>
    <td>73.189.246.202</td>

    <td>http://www.gmail.com</td&gt;

    <td>22:28</td>
    <td>1983/4/28</td>
    <td>28/4/1983</td>
    </tr>

    <tr>
    <td>muffins@flexomat.com</td>

    <td>90584</td>
    <td>941-964-4640</td>
    <td>$3706.01</td>
    <td>243.162.73.115</td>
    <td>http://www.fish.org</td&gt;
    <td>11:12</td>

    <td>1997/4/8</td>
    <td>8/4/1997</td>
    </tr>

    <tr>
    <td>foo@samba.org</td>
    <td>82966</td>

    <td>941-964-7245</td>

    <td>$1001.38</td>
    <td>255.182.148.252</td>
    <td>http://www.reno.gov</td&gt;
    <td>8:42</td>
    <td>1995/11/1</td>

    <td>1/11/1995</td>

    </tr>

    <tr>
    <td>foo@reno.gov</td>
    <td>03603</td>
    <td>941-964-8942</td>

    <td>$1677.07</td>
    <td>176.96.162.192</td>

    <td>http://www.flexomat.com</td&gt;
    <td>19:11</td>
    <td>1980/7/31</td>
    <td>31/7/1980</td>

    </tr>

  • And last part:
    	<tr>
    <td>found@flexomat.com</td>

    <td>84939</td>
    <td>941-964-7004</td>
    <td>$3916.83</td>

    <td>240.145.198.78</td>
    <td>http://www.fish.org</td&gt;
    <td>1:29</td>

    <td>1980/8/26</td>
    <td>26/8/1980</td>
    </tr>


    <tr>
    <td>henry@lostnfound.org</td>
    <td>76453</td>
    <td>941-964-3084</td>

    <td>$3875.88</td>
    <td>235.225.168.168</td>

    <td>http://www.fish.org</td&gt;
    <td>15:31</td>
    <td>2000/10/22</td>
    <td>22/10/2000</td>

    </tr>

    <tr>

    <td>sam@aftonbladet.se</td>
    <td>36274</td>
    <td>941-964-7784</td>
    <td>$73.43</td>
    <td>114.190.194.148</td>

    <td>http://www.dn.se</td&gt;

    <td>18:24</td>
    <td>1994/11/11</td>
    <td>11/11/1994</td>
    </tr>

    <tr>
    <td>dev@polyester.se</td>

    <td>15971</td>
    <td>941-964-7527</td>
    <td>$1855.18</td>
    <td>179.121.143.189</td>
    <td>http://www.flexomat.com</td&gt;
    <td>10:25</td>

    <td>1984/8/16</td>
    <td>16/8/1984</td>
    </tr>

    <tr>
    <td>devo@fish.org</td>
    <td>31734</td>

    <td>941-964-9760</td>

    <td>$3201.35</td>
    <td>213.186.220.205</td>
    <td>http://www.samba.org</td&gt;
    <td>19:37</td>
    <td>1979/3/4</td>

    <td>4/3/1979</td>

    </tr>

    <tr>
    <td>devo@reno.gov</td>
    <td>52074</td>
    <td>941-964-2068</td>

    <td>$3035.24</td>
    <td>189.62.225.163</td>

    <td>http://www.dn.se</td&gt;
    <td>21:18</td>
    <td>1998/2/24</td>
    <td>24/2/1998</td>

    </tr>

    <tr>
    <td>mendez@fish.org</td>

    <td>87800</td>
    <td>941-964-7933</td>
    <td>$618.59</td>

    <td>254.119.153.91</td>
    <td>http://www.dn.se</td&gt;
    <td>22:34</td>

    <td>1979/5/28</td>
    <td>28/5/1979</td>
    </tr>


    <tr>
    <td>muffins@reno.gov</td>
    <td>95926</td>
    <td>941-964-147</td>

    <td>$3897.91</td>
    <td>105.85.121.209</td>

    <td>http://www.flexomat.com</td&gt;
    <td>9:50</td>
    <td>2003/4/1</td>
    <td>1/4/2003</td>

    </tr>

    <tr>

    <td>carl@donuts.com</td>
    <td>74513</td>
    <td>941-964-4507</td>
    <td>$2150.68</td>
    <td>106.175.123.125</td>

    <td>http://www.fish.org</td&gt;

    <td>21:42</td>
    <td>1977/4/8</td>
    <td>8/4/1977</td>
    </tr>

    <tr>
    <td>sam@fish.org</td>

    <td>82420</td>
    <td>941-964-2134</td>
    <td>$3947.54</td>
    <td>129.78.102.122</td>
    <td>http://mountdev.net</td&gt;
    <td>11:33</td>

    <td>1990/11/26</td>
    <td>26/11/1990</td>
    </tr>

    <tr>
    <td>devo@mountdev.net</td>
    <td>81905</td>

    <td>941-964-3535</td>

    <td>$722.17</td>
    <td>229.101.84.111</td>
    <td>http://fish.org</td&gt;
    <td>7:29</td>
    <td>1975/12/28</td>

    <td>28/12/1975</td>

    </tr>

    <tr>
    <td>john@lostnfound.org</td>
    <td>93124</td>
    <td>941-964-1508</td>

    <td>$394.82</td>
    <td>61.184.235.77</td>

    <td>http://www.mountdev.net</td&gt;
    <td>14:38</td>
    <td>1979/12/10</td>
    <td>10/12/1979</td>

    </tr>
    </tbody>
    </table>



    <a name="bottom" href="#top">Go to top</a>
    </div>

    </body>
    </html>
  • Just a tip, we don't really need the HTML. What matters the most right now is the jQuery that you are trying to run.
  • And what have you put in your custom.js? Everything else is irrelevant as the custom.js file is where you tell JQuery to do something
  • Ofcourse, you're right.

    I took this example from the jquery website but for me it does't work:
    <button id="clickme">Click here</button>

    <p id="clickme">
    This is the paragraph to end all paragraphs. You
    should feel <em>lucky</em> to have seen such a paragraph in
    your life. Congratulations!
    </p>



    <script>
    $("button").click(function () {
    $("#clickme").slideToggle("slow");
    });
    </script>
  • Yeah actually I didn't put anything in my custom.js file, I had it right in my html document but forgot to paste it in my above posts..

    For some reason though, it is working now! I have no idea how or why that happened, I don't believe I changed anything really.. but the good thing is, it is working now! So thanks @TT_Mark and @BoringCode.