title: onclick attribute can't find Javascript function
body: <p>I can't manage to link my Javascript function to my 'onclick' html attribute in the span tag.<br />
  I keep getting the error:</p>
  <blockquote>
  <p>&quot;Uncaught ReferenceError: closeAndRefresh is not defined&quot; &quot;at
  HTMLSpanElement.onclick&quot;</p>
  </blockquote>
  <p>My code looks like this:</p>
  <pre><code>&lt;div class=&quot;error&quot;&gt;
      &lt;div id=&quot;errorMessage&quot;&gt;
          &lt;span onclick=&quot;closeAndRefresh();&quot;&gt;&amp;#10006;&lt;/span&gt;
          &lt;p id=&quot;message&quot;&gt;
              &lt;?php echo $confirmationMessage ?&gt;
          &lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;script&gt;
      function closeAndRefresh() {
          &lt;?php $visibility = 'hidden' ?&gt;
          window.location.reload(true);
      }
  &lt;/script&gt;
  </code></pre>
  <p>I'll also add a screenshot of my code:</p>
  <p><a href="https://i.stack.imgur.com/D2Cwg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D2Cwg.png" alt="enter image description here" /></a></p>