[jQuery] Re: a better selection method

2009-04-02 Thread brian
Much nicer. Thanks for the tip! On Thu, Apr 2, 2009 at 1:43 PM, mkmanning wrote: > > Actually there's an easier way as long as the links and the items > being hidden/show have a one-to-one relationship. > > $(document).ready(function(){ >  var a = $('ul.selector li a'), div = $('div.youtube').ch

[jQuery] Re: a better selection method

2009-04-02 Thread mkmanning
Actually there's an easier way as long as the links and the items being hidden/show have a one-to-one relationship. $(document).ready(function(){ var a = $('ul.selector li a'), div = $('div.youtube').children ('div'); a.click(function(){ $(div.hide().get(a.index(this))).show();

[jQuery] Re: a better selection method

2009-04-02 Thread brian
First, I'd change the HTML to: one two three 1 2 3 You should use IDs instead of classes because you want to target a specific element. I left the "selector" class be