Can someone explain why this doesn't work ? 3. Variables


#1


Hi. I am at a loss here as to why this doesn't work.
I'm stuck at this excercise:
https://www.codecademy.com/courses/web-beginner-en-GfjC6/0/3?curriculum_id=50a3fad8c7a770b5fd0007a1#

Here's my code
script.js

// Write your jQuery code on line 3!
$(document).ready(function() {
   var $target = ('ol li:nth-child(4)');
    $target.fadeOut('fast');
});

index.html

<!DOCTYPE html>
<html>
    <head>
        <title>Simplify, Simplify</title>
        <script type='text/javascript' src='script.js'></script>
    </head>
    <body>
        <div> Remember!
            <ul>
                <li>
                    <ol>
                        <li>Start with the function keyword</li>
                        <li>Inputs go between ()</li>
                        <li>Actions go between {}</li>
                        <li>jQuery is for chumps!</li>
                    </ol>
                </li>
                <li>Inputs are separated by commas.</li>
                <li>Inputs can include other functions!</li>
            </ul>
        </div>   
    </body>
</html>

I have also tried assigning a class="4" and changing
var $target = ('ol li:nth-child(4)');
to
var $target = ('#4');

Anybody got any suggestions ?


#2

to select an element with jquery:

$('ol')

in your case, the $ is missing

Also, classes use a . and id's use #, remember?


#3

Thank you. Of course.. It's always the small little things you miss..

Appreciate the help!


#4