title: Can I use a string variable in document.getElementById()?
body: <p>here is my code:</p>
  
  <pre><code>function figureSelector () {
      document.getElementById("rook").onclick = function  () {
          curr = '"rook"';
      };
  };
  
  function moveLine(){
      document.getElementById("upButton").onclick = function() { 
              document.getElementById(curr).style.top = document.getElementById(curr).offsetTop - getPix() * 62  + "px"; 
              counter= counter + getPix();
      }; 
  </code></pre>
  
  <p>I want to write an universal function for a chess piece to move. All I want is, when one clicks the chess piece, and then presses the up button, it must go up. </p>