title: JavaScript - code is not working - passing argument to function
body: <p>I am trying to understand bookmark application which I found on internet,here is the link for the code <a href="https://github.com/bradtraversy/bookmarker/blob/master/js/main.js" rel="nofollow noreferrer">https://github.com/bradtraversy/bookmarker/blob/master/js/main.js</a>
  Now in that code on <strong>line 85</strong> he build <code>button</code> element with <code>onclick</code> event,assign it to function <code>deleteBookmark()</code> and passed the argument <code>url</code> in it which then get recieved in <code>deleteBookmark()</code> function on <strong>line 55</strong> and his code works but when I tried to build similar kind of code to better understand what is happening in that application,my code does not work. I am using the code below.</p>
  
  <pre><code>    &lt;div id="divArgument"&gt;&lt;/div&gt;
      &lt;input type="text" id="argument"&gt;
      &lt;p id="displayArg"&gt;&lt;/p&gt;
      &lt;script&gt;
      var testArg = document.getElementById('divArgument');
      var getVal = document.getElementById('argument').value;
      testArg.innerHTML = '&lt;button onclick="sendArg(\''+getVal+'\')"&gt;Display Argument&lt;/button&gt;';
  
      function sendArg(recVal){
              document.getElementById('displayArg').innerHTML = recVal;
          } 
      &lt;/script&gt;
  </code></pre>