row to row-fluid with jQuery

row to row-fluid with jQuery

Is it a good idea and is it the best way to do that  ?

I just want to add -fluid  to the class row or container if the screen  < 1440  onload and on resize
and to refresh the page if it is resized under 1440

There is a shortest way to do that I guess

  1. $( window ).resize(function() {
  2.  
  3. var width = $(window).width(), height = $(window).height();
  4. if (width < 1440) {
  5. $('.container').addClass('container-fluid');
  6. $('.container-fluid').removeClass('container');
  7. $('.row').addClass('row-fluid');
  8. $('.row-fluid').removeClass('row');
  9. location.reload(true);
  10.    } else {
  11.     $('.container-fluid').addClass('container');
  12. $('.container').removeClass('container-fluid');
  13.     $('.row-fluid').addClass('row');
  14. $('.row').removeClass('row-fluid');
  15.    }
  16. });
  17. $(document).ready(function() {
  18. var width = $(window).width(), height = $(window).height();
  19. if (width < 1440) {
  20. $('.container').addClass('container-fluid');
  21. $('.container-fluid').removeClass('container');
  22. $('.row').addClass('row-fluid');
  23. $('.row-fluid').removeClass('row');
  24.    } else {
  25.     $('.container-fluid').addClass('container');
  26. $('.container').removeClass('container-fluid');
  27.     $('.row-fluid').addClass('row');
  28. $('.row').removeClass('row-fluid');
  29.    }
  30. });
Thank you