Hello. Tell me how to make the code run only with a screen width less than 992px
var toggle = $(".toggle"); var menu = $(".menu"); var link = $(".menu li"); var wid = $(window).width(); toggle.click(function(){ $(this).toggleClass("on"); menu.slideToggle(); return false; }); $(window).resize(function(){ if(wid > 992 && $(".menu").is(":hidden")) { $(".menu").removeAttr("style"); } }); // ЭТОТ КОД ДОЛЖЕН ВЫПОЛНЯТСЯ ТОЛЬКО ПРИ ШИРИНЕ МЕНЬШЕ 992px !!!! $(document).click(function(e){ if ($(e.target).closest(".menu").length) return; $('.menu').slideUp(); toggle.removeClass("on"); e.stopPropagation(); }); link.click(function(){ $(this).parent(".menu").slideUp(); toggle.removeClass("on"); }); // <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a class="toggle" href="#"><span></span>menu</a> <ul class="menu clearfix"> <li><a href="#test">item-1</a></li> <li><a href="#">item-2</a></li> <li><a href="#">item-3</a></li> </ul>