Well I have a menu and there I want to have an class called active
, when its active, obviously.
To toggle this class I am using the jQuery toggle function, but it does just activate it in the js element. If I check the dom element, this class is never set. But I need this class, because of my CSS styles.
I know that there are already many topics about toggleClass
jQuery, but they doesn't fit (at least I couldn't find anything suitable)
Here some code:
$('#menu').on('click', '.tab span', function (e) {
e.stopPropagation();
var $tab = $(this).parent('.tab');
$tab.siblings('.tab.active').removeClass('active');
$tab.toggleClass('active');
});
HTML markup
<div id="menu">
<div class="tab">
<span></span>
</div>
</div>
Its working in all browsers, except IE8 Thanks in advance.