Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

i 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

http://teamtreehouse.com/library/jquery-basics/introduction-to-jquery/-ways-to-include-jquery-in-a-project

2 Answers

Adam Moore
Adam Moore
21,956 Points

To 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.

thanks that worked

Adam Moore
Adam Moore
21,956 Points

It doesn't look like you've set the jQuery function equal to the variable myCode.

can u type me the text

plz show me a solution i am worried from past 30 min