title: Run JavaScript after the page loads (document.ready)
body: <p>I have the following script inside my master page :-</p>
  
  <pre><code>&lt;script type= "application/javascript"&gt;
  document.getElementById("currentdate").innerHTML = EMBEDformatAMPM();
  var myVar=setInterval(function(){myTimer()},30000);
  function myTimer()
  {
  document.getElementById("currentdate").innerHTML = EMBEDformatAMPM();
  }
  //code goes here
  }&lt;/script&gt;
  </code></pre>
  
  <p>but the problem i am facing is that the script will run before the <code>(currentdate").innerHTML</code> loads, and the script will raise a null reference exception, so my question is basically about how i can force the javaScript to run after the page loads.?
  Thanks</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>My jQuery file is raising the following error ,, not sure why :-</p>
  
  <pre><code>Error: Syntax error, unrecognized expression: unsupported pseudo: visited
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/JkmjP.png" alt="enter image description here"></p>