About this thread: https://discuss.codecademy.com/t/3-variables/54473


#1

As I copy/pasted the codes indicated on that forum thread, I still get an error message: "Did you create the $target variable on line 3?"
How to overcome it?


#2

please post your code here so we can see that .
then we'll tell you what step you should take :slight_smile:


#3

Indeed :slight_smile:

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>
                        <div class = "A"><li>jQuery is for chumps!</li></div>
                    </ol>
                </li>
                <li>Inputs are separated by commas.</li>
                <li>Inputs can include other functions!</li>
            </ul>
        </div>   
	</body>
</html>

ScriptJS

// Write your jQuery code on line 3!
$(document).ready(function() {
    var target = $(".A");
    $(target).fadeOut('slow');
})

#4

Create a variable called $target

so your code should be like

$(document).ready(function() {
var $target = $(".A");
$($target).fadeOut('slow');
})



to show html code here in the froum
1.paste your code in the froum
2.select all of your html code
3.click on the </> above


#5

@rcodeman I have formatted the code for you...


@laurentchollat Make sure you have a look at this guide:


#6

Hi,

Thanks for the support. Still struggling with the same error message. I do not know whenever it is the code itself that is causing the issue or whenever it is not targeting the correct line. Still working on it. In the meantime, here are the codes.
HTML code are:

<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>
                    <div class = 'p'><li>jQuery is for chumps!</li></div>
                </ol>
            </li>
            <li>Inputs are separated by commas.</li>
            <li>Inputs can include other functions!</li>
        </ul>
    </div>   
</body>

JQuery:
$(document).ready(function() {
var $target = $(".A");
$($target).fadeOut('slow');
})


#7

Thanks. Still struggling with the same error message


#8

In your fast post your class name was A

<div class = "A"><li>jQuery is for chumps!</li></div>

now you changed to p

<div class = 'p'><li>jQuery is for chumps!</li></div>

so you have to change the jQuery code too
var $target = $(".p");


#9

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