title: Is it possible to call local storage inside a function and use it in Windows.onload?
body: <p>I have a on click function which  return 'x' and stores in div dynamically. After a page refresh, this dynamic div resets and the data is gone. But i want the data to stay. To do that i stored that in local storage and want to call later when page loads. I store it in local storage inside the function 'test'
  and calling it in windows.onload which is returning null. I understand that i am unable to call the local storage inside the function. My question: Is there a way to call the local storage inside the function 'test'</p>
  <pre><code>function test(parameter1, parameter2) { // this is an onclick function
      
  // some functionality
          
   return x;
   var test = x.innerHTML;
   localStorage.setItem('somediv', test);
  
  }
  
  window.onload = function () {
  
      var test2 = localStorage.getItem('somediv')
      $('div.somediv').text(test2);
  
  
  }
  </code></pre>