 <p>It could be as simple as that:</p> <pre><code>var openAccordionContent = function () { $('.accordion-content-button').on('click', function () { var $next_content = $(this).next('.accordion-content'); // Remove the class show from all the items, except the one // sitting next to the clicked one. $('.accordion-content').not($next_content).removeClass('show'); // Toggle the class show for the item which is sitting next // to the clicked one. $next_content.toggleClass('show'); }); }(); </code></pre> <p><a href="https://jsfiddle.net/MelanciaUK/vx2bguyp/12/" rel="nofollow">Demo</a></p>