Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialharsha praneeth
5,449 Pointsi entered the same data as said in video but
i have pasted the below in index.html
<!DOCTYPE html>
<html>
<head>
<title>Take Evasive Action</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body>
</head>
<body>
<p class="warning">
<span>It's A Trap!</span>
</p>
<div class="image">
<img src="img/ackbar.gif" />
</div>
</html>
and in
app.js
//Hide Warning //Show Warning Slowly $(".warning").hide().show("slow");
$(document).ready(myCode);
but unable to see the out put shown in the video and here is the video link
2 Answers
Adam Moore
21,956 PointsTo make the code work with the$(document).ready(myCode)
function, you'll need to set your $(".warning").hide().show("slow");
to be equal to the myCode
variable that you are telling the function ready()
to do once the $(document)
is ready()
. (Also, not sure if you did this, but you have to make sure that you don't put any of your code that you want to run on the same line as a comment, as it seems like you did up above.) So, you would do it like this:
//Hide Warning
//Show Warning Slowly
var myCode = $(".warning").hide().show("slow");
$(document).ready(myCode);
Does that make sense? What you had before was simply the code (seemingly commented out) for the function to hide and show, and then the $(document).ready(myCode);
with a variable myCode
that wasn't set to anything yet. However, if you were to simply have the $(".warning").hide().show("slow");
on the page without the $(document).ready();
, it would still run if you put the link to your app.js at the end of index.html. This is because $(".warning").hide().show("slow");
is saying that you want jQuery to select $(".warning")
and hide()
it, then show("slow")
it slowly. Because this statement is, in fact, what jQuery is being told to do with this function, it will run without having to do anything else to start it.
Adam Moore
21,956 PointsIt doesn't look like you've set the jQuery function equal to the variable myCode
.
harsha praneeth
5,449 Pointscan u type me the text
harsha praneeth
5,449 Pointsplz show me a solution i am worried from past 30 min
harsha praneeth
5,449 Pointsharsha praneeth
5,449 Pointsthanks that worked