I'm working on a website which has a thumbnail navigation on it's about us page, and for each person you click their profile is displayed inside the same box. Then by clicking "close" at the bottom of the profile it takes you back to the thumbnails.

3 Answers
3

I just realized you wanted the total opposite of what I initially put, but for one: it would be good to name your id of your divs the exact name for your anchor tag as text so, and also in order to have a text to click on something must be inside your div:

This is along the right lines, but how do I hide the thumbnails after they are clicked. I'd like only one div at a time to show, including thumbnails.
–
SevenupcanJun 25 '09 at 12:41

this shows only one div. you want it to show only the profile link clicked also? but that would hide all the the others making you have to refresh the page in order to select another 'div'
–
TStamperJun 25 '09 at 14:21

Yeah that's what I'm after. Then there will be a link inside each profile that will let you go back to the thumbnails div.
–
SevenupcanJun 26 '09 at 14:24

just add these two lines: $('#thumbnails li a').hide(); $(this).show(); after the 'click' but before the 'each'
–
TStamperJun 26 '09 at 15:20

The reason for this is you want to put as little marker HTML in as possible. You could further change this by removing the IDs from the links if you can assume that you can infer the ID from the position within the list. That's just one possible alteration.

The use of IDs seems appropriate when you're marking page elements like container and thumbnails as well. Plus ID lookup is much, much faster than the alternatives.

Don't forget to 'return false;' at the end otherwise the link will be followed. Granted, it will just follow to 'URLhere#' but that could still be annoying because it will scroll the page to the top. ;)
–
KyleFarrisJun 23 '09 at 15:12

With this suggestion I wasn't able to stop the link from being followed even with return false. Did I get the syntax wrong?
–
SevenupcanJun 25 '09 at 12:38