Variables


#1

Although I passed the stage by directly putting $('#fourth') instead of the variable $target but I want to understand why my code didn't work with the $target variable?


<!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 id="fourth">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>

// Write your jQuery code on line 3!
$(document).ready(function() {
    
    $target.fadeOut('fast');
});

var $target = $('#fourth');

#2

you should declare target inside the document ready function content


#3

Thank you :thumbsup:

But again this code doesn't work

$(document).ready(function() {
var $target = $('ol:nth-child(4)');
$target.fadeOut('fast');
});


#4

if you don't, nothing will trigger the var $target = $('#fourth'); code to run


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.