1. tabContent2 : holds the collection of DIVs that are immediate children of
#tabcontent
2. filter(':visible') : reduces the collection from (1) to just those DIVs
that are visible (ie probably the one that had previously had show() run on
it) because it is not necessary to hide those that already hidden!
3. hide() : hides the (reduced) collection from (2), ie sets display:none
4. end() : reverts the last 'destructive' action, which was the filter in
(2), so the collection is now back to as it was in (1)
5. filter(':eq('+(n+1)+')') : reduces the collection down to a single item,
that item being the (n+1)th of the current collection (from (1)). So if you
are adding the handler for the first anchor, n is 0, therefore the selector
is ':eq(1)', which cuts the collection down to just the second DIV in the
initial tabContent2 collection (the first DIV being the one that is only
displayed if no menu option has been clicked?)
6. show() : shows the current collection from (5) - just one item! - ie.
sets display:block
7. end() : reverts the last 'destructive' action, which was the filter in
(5), so the collection is now back to the same as it started out in (1) ...
again!

Make sense?


dogslife wrote:
> 
> Thank you very much, that function did exactly what I was looking for. If
> you have time, would you mind breaking down how this line works?
> tabContent2.filter(':visible').hide().end().filter(':eq('+(n+1)+')').show().end();
> 
> I know your comment (" hide any div currently visible, and show the nth+1
> div...") explains "what", but I was wondering "how" it works.
> 
> Thank's again!
> 

-- 
View this message in context: 
http://www.nabble.com/show-hide-div-with-menu-tf4411247s15494.html#a12598527
Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to