title: Javascript - get undefined when trying to get value of element that clearly stated in HTML
body: <p>I try to make simple html with javascript for studying html. But when I run the html in browser, it return undefined in console log when trying to get Button 1 and Button 2 value.</p>
  
  <p>Html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;script src="js/Try.js"&gt;&lt;/script&gt;
  &lt;head&gt;
      &lt;title&gt;Try&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div class="wrapper"&gt;
          &lt;div&gt;
              &lt;a type="button" id="Button1" href="#" value="B1" onmouseover="PutValueLog(this)"&gt;Button 1&lt;/a&gt;
              &lt;a type="button" id="Button2" href="#" value="B2" onmouseover="PutValueLog(this)"&gt;Button 2&lt;/a&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>var tempval;
  
  function PutValueLog(button){
      tempval = button.value;
      console.log(button);
      console.log(tempval);
  }
  </code></pre>
  
  <p>And the console log that I get:</p>
  
  <p><img src="https://i.stack.imgur.com/A9gel.png" alt="log image"></p>
  
  <p>Can anyone tell me why that happen? What I must do to get value not undefined but B1 or B2 in my console log?</p>