Title: Active or current class
Last modified: August 21, 2016

---

# Active or current class

 *  [berbercito](https://wordpress.org/support/users/berbercito/)
 * (@berbercito)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/active-or-current-class/)
 * Hi, I have just come across your nice plugin. It does exactly what I was looking
   for however I think it would be even nicer if it could detect the opened accordion
   and add to its toggle link an active class name. This way we can style it the
   way we want.
    Do you think it is easy to be done. Thanks a lot in advance.
 * [https://wordpress.org/plugins/q-and-a/](https://wordpress.org/plugins/q-and-a/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [bnafz](https://wordpress.org/support/users/bnafz/)
 * (@bnafz)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/active-or-current-class/#post-4778315)
 * I would also like this ability.
 * Anyone know how this could be accomplished? I’ve tried a few things with jQuery
   but my knowledge with jQuery is limited.
 * Thanks in advance.
 *  [Tsun4Ever](https://wordpress.org/support/users/tsun4ever/)
 * (@tsun4ever)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/active-or-current-class/#post-4778337)
 * Hi guys,
 * i just needed this function also for one of my project, here is my quick solution:
 * A bit off css
    `a { background: transparent url(img/sprites.png) -50px 0 no-repeat;
   padding-left: 25px; &.active { background-position-y: -26px; } }`
 * a bit of javascript :
 *     ```
       if ($('.faq-list').length >0) {
                   $('a.qa-faq-anchor').on('click', function(event) {
                       $(this).toggleClass('active');
                   });
               }
       ```
   
 * Hope that help,
 * Cheers
 *  [bnafz](https://wordpress.org/support/users/bnafz/)
 * (@bnafz)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/active-or-current-class/#post-4778348)
 * Hi,
 * Thank you. The code worked perfectly.
 * I had to make sure “Accordion behavior” was unchecked in the admin area because
   when the plugin automatically closes an FAQ, it kept the active class appended.
 * Thanks again for the code!!
 *  [Tsun4Ever](https://wordpress.org/support/users/tsun4ever/)
 * (@tsun4ever)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/active-or-current-class/#post-4778350)
 * no problem 🙂
 * actually, a better code will be this one :
 *     ```
       $('a.qa-faq-anchor').on('click', function(event) {
                       if (!$(this).hasClass('active')) {
                           $('a.qa-faq-anchor.active').removeClass('active');
                       }
                       $(this).toggleClass('active');
                   });
       ```
   
 * to take in account the case where there is only one category and the case where
   the user is clicking on an open category.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Active or current class’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/q-and-a.svg)
 * [Q and A FAQ and Knowledge Base for WordPress](https://wordpress.org/plugins/q-and-a/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/q-and-a/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/q-and-a/)
 * [Active Topics](https://wordpress.org/support/plugin/q-and-a/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/q-and-a/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/q-and-a/reviews/)

## Tags

 * [active](https://wordpress.org/support/topic-tag/active/)

 * 4 replies
 * 3 participants
 * Last reply from: [Tsun4Ever](https://wordpress.org/support/users/tsun4ever/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/active-or-current-class/#post-4778350)
 * Status: not resolved