treehouse : what would you like to learn today?
Web Design Web Development iOS Development

jQuery Window Resize (do this when window is resized to this width)

  • Hi, Okay first off if you are here then I am assuming that you know about responsive web design. Also you know about CSS3 media queries. Okay so here is what I want to do when the browser/window is resized to less then 700 pixels I want following things to happen

    you know jquery append other usual stuff.

    but the thing is It just won't work. I tried a snippet that css-tricks.com provided in an article years back but had no success with it.

    In simple terms when the window/browser is lower then 700 then I want to do other things with jquery.

  •   window.onresize = function(event) {
          viewportwidth = $(window).width();
          if (viewportwidth<700) {
              // some jquery stuff here;
          }
      }
    
  • Thanks for the quick reply. I will try it out as soon as I can.