Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Robert Walker
Robert Walker
16,514 Points

Help with hide/show

Problem fixed.

Thank you Shawn for trying to help seems I had too many ); in my code.

Massive idiot that I am after checking it over and over for so many hours. =(

Shawn Flanigan
Shawn Flanigan
Courses Plus Student 15,815 Points

No problem. Glad you figured it out! I can't tell you how many hours I've wasted looking for extra semicolons...or mis-matched single/double quotes.

2 Answers

Shawn Flanigan
PLUS
Shawn Flanigan
Courses Plus Student 15,815 Points

Robert: Where on the page are you calling the script? If you're calling it in the head, or high on the page, it may be looking for elements that don't exist yet. I wonder if moving it to the end of the body would help?

Robert Walker
Robert Walker
16,514 Points

Hi Shawn, I have it in my footer currently to see if that was the issue too but still no joy.

As I say ive spent the best part of 8 hours trying to get this working and no matter how I do it I can not for the life of me get it to work.

It is only those elements though every other id and class work, I am a JS newbie and thought maybe it has something to do with the elements being generated by the PHP.

Completely stuck and out of ideas on how to fix it myself.

Just to add, by in the footer I mean right above the closing body tag.

Shawn Flanigan
Shawn Flanigan
Courses Plus Student 15,815 Points

Strange. Have you tried the .on() event handler instead of .click()? Might be worth a shot. Something like... ("#hide").on("click", function(){("#harry").toggle();});

Robert Walker
Robert Walker
16,514 Points

Thanks again Shawn for your help.