title: this.id corresponds to variable
body: <p>I have a list of variables that correspond to numbers. I use these variables to write numbers to a &quot;screen&quot; in a web app I'm building for fun.</p>
  <pre><code>var zero = 0;
  var one = 1;
  var two = 2;
  var three = 3;
  var four = 4;
  var five = 5;
  var six = 6;
  var seven = 7;
  var eight = 8;
  var nine = 9;
  var dec = &quot;.&quot;;
  var neg = &quot;-&quot;;
  </code></pre>
  <p><img src="https://i.stack.imgur.com/UQyG6.png" alt="example Image" /></p>
  <p>I used to have a long list of <code>onclick</code> functions for each of the buttons:</p>
  <pre><code>$('#a0').click(function(){
      writeInput(input, zero);
  });
  
  $('#a1').click(function(){
      writeInput(input, one);
  });
  $('#a2').click(function(){
      writeInput(input, two);
  });
  ...
  </code></pre>
  <p>I want to convert all of these click functions into something like this:</p>
  <pre><code>$('.btnA').click(function(){
      var id = this.id;
      writeInput(input, id);
  });
  </code></pre>
  <p>Which calls this function:</p>
  <pre><code>function writeInput(field, str){
  var text = $(field).val(function(i, v){
                return v + str;
             }).text(function(i, t){
                return t + str
             }).val();
  convert(text, version);
  </code></pre>
  <p>}</p>
  <p>All of the buttons on the number input above have this HTML:</p>
  <pre><code>...
  &lt;a id=&quot;seven&quot; class=&quot;btnA&quot;&gt;&lt;div class=&quot;inputBtn mar&quot; id=&quot;input7&quot;&gt;7&lt;/div&gt;&lt;/a&gt;
  &lt;a id=&quot;eight&quot; class=&quot;btnA&quot;&gt;&lt;div class=&quot;inputBtn mar&quot; id=&quot;input8&quot;&gt;8&lt;/div&gt;&lt;/a&gt;
  &lt;a id=&quot;nine&quot; class=&quot;btnA&quot;&gt;&lt;div class=&quot;inputBtn&quot; id=&quot;input9&quot;&gt;9&lt;/div&gt;&lt;/a&gt;
  ...
  </code></pre>
  <p>My question is: Can I get the id name from the <code>&lt;a id=&quot;nine&quot; class=&quot;btnA&quot;&gt;</code> and have it correspond to the <code>var nine = 9;</code></p>
  <p>I hope this made sense. If not please ask I will answer any questions. Thanks!</p>