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
Rhoda Toynbee
18,938 PointsJavaScript not responding on Chrome or Safari
I am working through the jQuery Basics lessons. The "warning it's a trap" and "spoiler alert" worked fine on Chrome. When I started working through the "Hidden Menu" my menu wasn't "hiding". I figured I just messed up somewhere, spent forever rechecking my code and then gave up. I followed along until the end of the project and opened the last project workspace with all his pre-done code. Still not working. I Googled how to check that my JavaScript was working. It says it's on and working fine. Switched to Safari. Still not working. I cleared my cache a few times as well.
Now I am working on the "password length with hints" project and it's still not working. Super frustrated because I would like to be able to check and make sure my code is working properly...and I get nothing.
Ideas? Suggestions? Something that I might have enabled or disabled that I should know about?
Thanks :)
Rhoda
Rhoda Toynbee
18,938 PointsIt's not one specific set of code. It happened on two separate projects :/
Here is the code from the latest project:
//Problem: Hints are shown even when form is valid
//Solution: Hide and show them at appropriate times
//Hide hints
$("form span").hide();
//When event happens on password input
$("#password").focus(function(){
//Find out if password is valid
if$(this).val().length > 8
//Hide hint if valid
$(this).next().hide();
} else {
//else show hint
$(this).next().show();
}
});
//When event happens on confirmation input
//Find out if password and confirmation match
//Hide hint if match
//else show hint
And the links to the JavaScript files from the index.html file.
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
2 Answers
Chris Shaw
26,676 PointsHi Rhoda,
The only issue I see with your code is you have a syntax error relating to your IF statement, currently it isn't wrapping the expression with parenthesis and doesn't have an opening curly brace, see the below code which I've removed the comments from to make it clearer as to what has changed.
$("#password").focus(function() {
// before: if$(this).val().length > 8
// after: if ($(this).val().length > 8) {
if ($(this).val().length > 8) {
$(this).next().hide();
} else {
$(this).next().show();
}
});
Rhoda Toynbee
18,938 PointsOk. I messed with it some more. I even downloaded the project files and messed with them in Sublime.
It was that closing parentheses. I didn't catch it the first time, just looked at the $. Thanks for your help!
I'm happy to know its just my dumb typos and not my browser :) oy!
Rhoda
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsHi Rhoda,
Could you please share the code you're trying to use as without it we can't determine the root cause of the issue.
https://teamtreehouse.com/forum/posting-code-to-the-forum