I'm building a responsive nav which behaves like an accordion on mobile (using Wordpress).
The code works fine, with one exception: if an accordion section is open on mobile and the screen is resized to desktop, it stays open on mobile i.e. I want the "-is-active" class to be removed about 900px. Where am I going wrong?
html
<div class="site-footer__container">
<div class="site-footer__header">
<img class="left desktop" src="<?php bloginfo('stylesheet_directory'); ?>/assets/images/logo-jpmorgan.png" alt="JPMorgan Chase Logo">
<img class="left mobile" src="<?php bloginfo('stylesheet_directory'); ?>/assets/images/logo-jpmorgan-small-brown.png" alt="JPMorgan Chase Logo">
<a class="site-footer__back right" href="#top">TOP</a>
</div>
<div class="site-footer__menu">
<?php
wp_nav_menu( array(
'menu' => 'footer_menu',
'container' => false,
'menu_class' => 'footer-menu'
) );
?>
</div>
</div>
js
if(jQuery(this).width() < 900) {
jQuery('.site-footer .footer-menu > .menu-item-has-children > a').on('click', function(e) {
e.preventDefault();
jQuery(this).siblings().toggleClass('-is-active').parent().toggleClass('-is-active');
});
} else {
jQuery('.site-footer .footer-menu > .menu-item-has-children > a').removeClass('-is-active')
}