0

Here's my code so far:

$('.faq dd').hide();
$('.faq dt').click(function(){
    $(this).next().slideToggle('normal');
});

I would like the DT to include an "active" class whenever someone clicks on it and then an "inactive" class whenever someone clicks on it again.

How is that possible?

2 Answers 2

5

With .toggleClass, you can toggle a class. Why would you play on 2 classes ?

$('.faq dd').hide();
$('.faq dt').click(function(){
    $(this).toggleClass('active').next().slideToggle('normal');
});
Sign up to request clarification or add additional context in comments.

1 Comment

Fastest gun in the west :P
0

You can use toggleClass, first assign inactive class to dt element and give active in toggle class. It will switch between inactive active class for dt.

$('.faq dd').hide();
  $('.faq dt').click(function(){
     $(this).toggleClass('active');  
     $(this).next().slideToggle('normal');
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.