title: Getting the id of a button just clicked
body: <p>I'm trying to create a calculator webapp using JS and I'm running into some problems. I looked at other open threads and tried that code but it didn't seem to work. I'm currently just trying to log the ID of the button that was pressed, but when I press a button all I get is <code>"undefined"</code> back. Here's my code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Calculator&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;p id="text"&gt;
  &lt;table border="0" id="table"&gt;
    &lt;tr&gt;
    &lt;td&gt;&lt;input type="button" id="one" value="1" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="button" id="two" value="2" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="button" id="three" value="3" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
    &lt;td&gt;&lt;input type="button" id="four" value="4" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="button" id="five" value="5" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="button" id="six" value="6" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
    &lt;td&gt;&lt;input type="button" id="seven" value="7" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="button" id="eight" value="8" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="button" id="nine" value= "9" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;&lt;input type="button" id="zero" value="0" onClick="calculate();"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
  &lt;/table&gt;
  
  
  
  
  &lt;script&gt;
  function calculate(){
  console.log(this.id);
  }
  
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>