detecting screen size when resizing browser

detecting screen size when resizing browser

Hi,

I would like to prepend an element on my screen when the bowser is resized.
my code works if I refresh my browser less than 500px but it doesn't work if I resize the browser

please help


  1. $(window).resize(function() { 
  2. if ($(window).width() < 500) { 
  3. $(".last-col").prependTo(".celeb-quote"); 
  4. });