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 Text Inputs Code Challenge not working

This is a lovely issue. The code challenge is giving me this error on task #2: Bummer! You did not call next() on $(this) and showed the returned element Yet, that's EXACTLY what I'm doing in my code: $("input, textarea").on('keydown', function(){$(this).next().show();});

I would also like to mention that I can test this in the preview and It does indeed work.

2 Answers

Ok, nevermind. It looks like they REQUIRE you to use the actual keydown function. I personally think that any valid jQuery method should be used as I'm a believer of only using the "on" method.

Thanks Sean! So it sounds like the correct response (according to Treehouse) would be the following:

$("input, textarea").keydown(function(){ $(this).next().show(); });

I also learned that it is better to use the "on" method, especially in the case of click. What is the advantage or difference in using the actual keydown or click function in place of the .on method?