Well I should also say I want it to deselct when another h2 element is clicked.
Michael Geary-3 wrote: > > > That's no problem, we are all newbies at something. > > So you just want the H2 element to get an 'active' class when you click on > it? Then add this inside the click function: > > $(this).addClass('active'); > > -Mike > >> From: yellowboy >> >> Yes, that is why I am seeking some assistance. >> >> Not sure how to implement it within my current code. I know >> how to assign the class as active, but how would I go about >> making it assign an active class to the h2 element when it is >> selected? >> >> Needless to say I'm a bit of a newbie and was just hoping for >> some suggestions. Thanks >> >> >> Michael Geary-3 wrote: >> > >> > >> > I don't see anything in your code that resembles your >> description of >> > what you want. I'd expect to find an addClass('active') >> call in there >> > somewhere. >> > I see a bunch of other code, but nothing like that. >> > >> > Perhaps that is the problem, the code you need simply isn't there? >> > >> > -Mike >> > >> >> From: yellowboy >> >> >> >> I want my h2 element to be assigned class 'active' when >> selected, I >> >> have tried numerous methods but to no avail, some guidance >> would be >> >> appreciated! >> >> >> >> function initMenus() { >> >> $('div.menu div.gallery').hide(); >> >> $.each($('.menu'), function(){ >> >> $('#' + this.id + '.expandfirst >> >> div.gallery:first').show(); >> >> }); >> >> $('div.menu h2').click(function() { >> >> >> >> var checkElement = $(this).next(); >> >> var parent = this.parentNode.parentNode.id; >> >> >> >> if($('#' + parent).hasClass('noaccordion')) { >> >> $(this).next().slideToggle('normal'); >> >> return false; >> >> } >> >> if((checkElement.is('div.gallery')) && >> >> (checkElement.is(':visible'))) { >> >> if($('#' + >> >> parent).hasClass('collapsible')) { >> >> $('#' + parent + ' >> >> div.gallery:visible').slideUp('normal'); >> >> } >> >> return false; >> >> } >> >> if((checkElement.is('div.gallery')) && >> >> (!checkElement.is(':visible'))) { >> >> $('#' + parent + ' >> >> div.gallery:visible').slideUp('normal'); >> >> checkElement.slideDown('normal'); >> >> return false; >> >> } >> >> } >> >> ); >> >> } >> >> $(document).ready(function() {initMenus();}); >> >> -- >> >> View this message in context: >> >> http://www.nabble.com/Assign-%27active%27-to-nav-element-tp197 >> > 53801s27240p19753801.html >> >> Sent from the jQuery General Discussion mailing list archive at >> >> Nabble.com. >> >> >> > >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Assign-%27active%27-to-nav-element-tp197 > 53801s27240p19754447.html >> Sent from the jQuery General Discussion mailing list archive >> at Nabble.com. >> > > > -- View this message in context: http://www.nabble.com/Assign-%27active%27-to-nav-element-tp19753801s27240p19758011.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.