Woah, thanks! It worked! I was bent on the idea that selectors had to have quotation marks. I suppose (in this case at least) thats untrue. Thank you.
On Mar 31, 11:14 pm, Ricardo <ricardob...@gmail.com> wrote: > Actually this is the perfect opportunity to put those href's into use: > > <div id="tab_links"> > <a href="#tab_1" class="active">slide 1</a> > <a href="#tab_2">slide 2</a> > <a href="#tab_3">slide 3</a> > </div> > > <div id="tabs"> > <div id="tab_1">slide 1</div> > <div id="tab_2">slide 2</div> > <div id="tab_3">slide 3</div> > </div> > > The script: > $('#tab_links a').click(function(){ > var activeTab = $(this).attr('href'); > $(activeTab).fadeIn(500); > return false; > > }); > > Even with your way you could have kept the IDs valid and have it work > the same: > ... > <a href="#" id="link_tab_2">slide 2</a> > > var activeTab = $(this).attr('id').substring(5); > $('#'+activeTab).fadeIn(500); > > (you could also use $(this).attr('id').replace('link_', '') ) > > cheers, > - ricardo > On Mar 31, 10:25 pm, James <james.gp....@gmail.com> wrote: > > > You're making it more complicated than it really is. > > Using something similar to Jonathan's method: > > > // Change your id to something like 'link_1', like here: > > <a href="#" id="link_1" class="active">slide 1</a> > > > var activeTabID = $(this).attr('id'); // -> link_1 > > var activeTab = activeTabID.split('_')[1]; // -> 1 > > $('#tab_'+activeTab).fadeIn(500); // fadeIn element with ID 'tab_1' > > > On Mar 31, 3:04 pm, Warfang <warfang...@gmail.com> wrote: > > > > Could I do something like this?... > > > > var activeTab = $(this).attr('id'); > > > $(''#(activeTab)'').fadeIn(500); > > > > Those are two single quotes by the way. That is what I would like to > > > accomplish.