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

JavaScript

Jquery 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

I'm not good at jquery but what i use in simple javascript is replace the .hide(); with .style.visibility = 'hidden';

Thanks for your help but that didn't work either :(

It must be something else wrong then, both the .hide() and my suggestion should work. What's your full code?

<!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>

it's displaying weird, sorry not sure how to fix that either

@Trinity - Indent each line of your code with 4 spaces, so it will be formatted correctly by the forum.

Thanks James!

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

@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

I 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!

Was anybody able to enhance this answer? I keep returning null....

thanks Michael I knew it had to be something like that. Cheers!

I 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!

Have 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>

I 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>

Put it in the .js file and it works :)