jquery - IE8 toggleClass not working properly -
well have menu , there want have class called active
, when active, obviously.
to toggle class using jquery toggle function, activate in js element. if check dom element, class never set. need class, because of css styles.
i know there many topics toggleclass
jquery, doesn't fit (at least couldn't find suitable)
here 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 browsers, except ie8 in advance.
try instead:
$('#menu').on('click', '.tab span', function (e) { e.stoppropagation(); var $tab = $(this).parent('.tab'); $tab.addclass('active').siblings('.tab').removeclass('active'); });
Comments
Post a Comment