Hi all,

First off, I am a bit new to jQuery so please excuse any newbie-ness.
Thank you all for the great group. It is extremely informative and I
hope to be able to give back soon.

I have been working with multiple jQuery scripts at
http://dev.betweenbrain.com/telos_systems/Support/supportRev3.5.html.
Everything seems to work as desired, except I am adding / removing a
class on .click to the links within the lower-left (FAQ) accordion
menu. The class is added fine, removed from siblings within the same
div, but doesn't remove the class from other links within the other
div. All divs have the same classes. Give it a try: Click on a
question to reveal the answer, then toggle the accordion menu, click
on a link, and then toggle back. You'll see what I mean.

The FAQ script is as follows:

$(document).ready(function() {
  var hideFaqs = function() {
        $('.faqs > div').hide();
}
  hideFaqs();
  $('.faqLink a').each(function(index) {
        $(this).click(function(){
        $(this).parents('.faqLink').find('a').removeClass('active');
        $(this).addClass('active');
          hideFaqs();
          $('.faqs > div:eq(' + index + ')').show();
          return false;
        });
  });
});

The accordion menu script is:

$(document).ready(function() {
        $('div.accordianMenu> div').hide();
        $('div.defaultOpen').show();
                $('div.accordianMenu> h3').click(function() {
                $(this).addClass('active').siblings('h3').removeClass('active');
                        var $nextDiv = $(this).next();
                        var $visibleSiblings = $nextDiv.siblings('div:visible');
                        if ($visibleSiblings.length ) {
                                $visibleSiblings.slideToggle('slow', function() 
{
                                $nextDiv.slideToggle('slow');
                                });
                         } else {
                        $nextDiv.slideToggle('slow');
                }
        });
});

(props to Karl Swedberg for the basis of the accordion menu)

Any thoughts on how to better remove the class of 'active' from the
FAQ link siblings would be greatly appreciated. Maybe I can add a
'removeClass' to the accordion script when it toggles?

Thanks,

Matt

Reply via email to