title: Storing document.getElementById in a variable?
body: <p>I have this script that is supposed to change the text of the button when the button is clicked.</p>
  
  <pre><code>&lt;body&gt;
     &lt;button onclick="toggleText(this);" id="id"&gt;Edit&lt;/button&gt;
  &lt;/body&gt;
  
  function toggleText(element){
      var text = document.getElementById(element.id).textContent;
  
      if (text == 'Edit') {
          text = 'Done';
      } else {
          text = 'Edit';
      }
  }
  </code></pre>
  
  <p>But it doesn't work. It only works when you put <code>document.getElementById(element.id).textContent</code> directly into the if statements.</p>
  
  <p>How do I get the variable to store properly?</p>