title: how to call window resize on window load in jquery
body: <p>I have a resize function that when you resize a window to that width the contents within it change.How do i achieve this on window load? I have tried the following</p>
  
  <p>attempt 1</p>
  
  <pre><code>$(window).load(function () {
         updateDivsMargins();
  
          $(window).resize(updateDivsMargins);
  
          function updateDivsMargins() {
                  var windowWidth = $(window).width();
                  if (windowWidth &gt;= 2560) {
                      alert("hello im 2560")
                      $('.1').css('margin-left', '500px');
                      $('#2').css('margin-right', '-300px');
                      $('#3').css('margin-left', '550px');
                      $('#4').css('margin-right', '-28em');
                  }
  
          }
  
      });
  </code></pre>
  
  <p>attempt 2</p>
  
  <pre><code>$(window).on("resize", function () {
              var windowWidth = $(window).width();
              if (windowWidth &gt;= 2560) {
                  alert("hello im 2560")
                  $('.1').css('margin-left', '500px');
                  $('#2').css('margin-right', '-300px');
                  $('#3').css('margin-left', '550px');
                  $('#4').css('margin-right', '-28em');
              }
          }).resize();
  </code></pre>
  
  <p>so only when i resize my page then the changes get taken into effect which is what i want.But if i load the page on 2560 it doesn't take in the changes.
  So my question i pose is how do i get it to load and resize. whats wrong with my above two attempts that doesn't take effect on load.</p>