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

Brett Smith
4,261 PointsjQuery works in Chrome console but not in JS file
When I add the following code via my app.js file it doesn't work but it works perfectly in my browser's console.
$(document).ready(function() {
if ($('#search').val().length > 0) {
$('.panel').removeClass('hidden');
} else {
$('.panel').addClass('hidden');
}
});
3 Answers

Kyle Daugherty
16,441 PointsDid you remember to add the script tag in your html file?
<script src="app.js"></script>

Brett Smith
4,261 Pointslol, yes I did. Other scripts are working fine.

Chris Shaw
26,676 PointsHi Brett,
Are you including this code after jQuery in the page? If not move it so it load after jQuery and it should work fine but without seeing your HTML it's hard to assume anything other than that.