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 trial
Trinity Doyle
1,542 PointsJquery Form Validation and Manipulation Text input events task 1/2
Hi,
I'm trying to hide all elements with the class of 'hint'. This is the code I'm using $(".hint").hide(); it keeps returning null, what am I doing wrong?
14 Answers
Matthew Ong
6,041 PointsI'm not good at jquery but what i use in simple javascript is replace the .hide(); with .style.visibility = 'hidden';
Trinity Doyle
1,542 PointsThanks for your help but that didn't work either :(
Matthew Ong
6,041 PointsIt must be something else wrong then, both the .hide() and my suggestion should work. What's your full code?
Trinity Doyle
1,542 Points<!DOCTYPE html>
<html>
<head>
<title>Text Input Events</title>
</head>
<body>
<p>
<input type="text"><span class="hint">Type in something cool</span>
</p>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="app.js">
$(".hint").hide();
</script>
</body>
</html>
Trinity Doyle
1,542 Pointsit's displaying weird, sorry not sure how to fix that either
James Barnett
39,199 Points@Trinity - Indent each line of your code with 4 spaces, so it will be formatted correctly by the forum.
Trinity Doyle
1,542 PointsThanks James!
James Barnett
39,199 Points@Trinity - You're welcome.
You can read all about the other ways to format forum posts on the Markdown Cheatsheet which is linked below each forum reply text box.
Michael Maliniak
2,441 Points@Trinity, your javaScript won't run due to the "src=app.js" attribute, the code inside that element won't run ..you need to start a new script element after it..one for allocating where the javascript file is located, one for the actual code itself. Hope that helps
L McLean
Courses Plus Student 5,329 PointsI have the same exact code as Trinity and I see the scp=app.js attribute, but I don't quite understand how to "run a new script after it...one for allocating where the javascript is located". Because I didn't see that in the video. Thanks for your help!
Brandon Harvey
5,709 PointsWas anybody able to enhance this answer? I keep returning null....
Trinity Doyle
1,542 Pointsthanks Michael I knew it had to be something like that. Cheers!
L McLean
Courses Plus Student 5,329 PointsI have the same exact code as Trinity and I see the scp=app.js attribute, but I don't quite understand how to "run a new script after it...one for allocating where the javascript is located". Because I didn't see that in the video. Thanks for your help!
Tony McCabe
8,445 PointsHave the same problem? I'm new to all this computer programming, but love it... it works the mind. Anyways any one have any suggestions? <!DOCTYPE html> <html> <head> <title>Text Input Events</title> </head> <body>
<p>
<input type="text"><span class="hint">Type in something cool</span>
</p>
<script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="app.js"> $(".hint").hide(); </script> </body> </html>
Steve Linn
11,841 PointsI had the same problem - it just keeps resulting in null - then I just refreshed the screen and entered it again and it passed
on the html page -----
<script type="text/javascript"> $('.hint').hide(); </script>
Kyle Bridges
Courses Plus Student 5,160 PointsPut it in the .js file and it works :)