title: How to change button text or link text in JavaScript?
body: <p>I have this HTML button:</p>
  
  <pre><code>&lt;button id="myButton" onClick="lock(); toggleText(this.id);"&gt;Lock&lt;/button&gt;
  </code></pre>
  
  <p>And this is my <code>toggleText</code> JavaScript function:</p>
  
  <pre><code>function toggleText(button_id) 
  {
     if (document.getElementById('button_id').text == "Lock") 
     {
         document.getElementById('button_id').text = "Unlock";
     }
     else 
     {
       document.getElementById('button_id').text = "Lock";
     }
  }
  </code></pre>
  
  <p>As far as I know, button text (<code>&lt;button id="myButton"&gt;Lock&lt;/button&gt;</code>) is just like any link text<br>
   (<code>&lt;a href="#"&gt;Lock&lt;/a&gt;</code>). So the fact that it's a button doesn't matter. However, I can't access the button text and change it.</p>
  
  <p>I tried <code>('button_id')</code>, <code>(button_id)</code>, <code>== "Lock"</code>, <code>== 'Lock'</code>, but nothing works.</p>
  
  <p><strong>How can I access and change a button text (not value) or a link text?</strong></p>