title: Jquery conditional fade by window width
body: <p>I would like to make the submenu fadeIn, but only above 850px window width. My code only works if I refresh the page, but I'd like to make it when I resize the window ( or change phone orienation ) as well. What's wrong?</p>
  
  <pre><code>function WinSize() {
      var winwidth = $(window).width();
      if (winwidth &gt; 850) {
          $('#main-menu &gt; ul &gt; li').on({
              mouseenter: function() {
                  $(this).find("ul").fadeIn(300);
              },
              mouseleave: function() {
                  $(this).find("ul").fadeOut(300);
              }
          });
      }
  }
  
  $(window).on("load resize", WinSize);
  </code></pre>