title: Add javascript global variable inside function
body: <p>Does anyone know how to use a global declared variable inside the following function?</p>
  
  <p>Global value:</p>
  
  <pre><code>window.waarde = document.getElementById("id_x").value;
  </code></pre>
  
  <p>Function:</p>
  
  <pre><code>$(function () {
    $('input[value="This is where the variable should be"]')
      .filter(':visible:first')
      .prop('checked', true);
  });
  </code></pre>
  
  <p>I've looked everywhere but can't find an answer.</p>