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

Robert Walker
Robert Walker
17,146 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
17,146 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
17,146 Points

Thanks again Shawn for your help.