title: JavaScript: get custom button's text value
body: <p>I have a button that is defined as follows :</p>
  <pre><code>&lt;button type=&quot;button&quot; id=&quot;ext-gen26&quot; class=&quot; x-btn-text&quot;&gt;button text here&lt;/button&gt;
  </code></pre>
  <p>And I'm trying to grab it based on the text value. Hhowever, none of its attributes contain the text value. It's generated in a pretty custom way by the look of it.</p>
  <p>Does anyone know of a way to find this value programmatically, besides just going through the HTML text? Other than attributes?</p>
  <p>Forgot one other thing, the id for this button changes regularly and using jQuery to grab it results in breaking the page for some reason. If you need any background on why I need this, let me know.</p>
  <p>This is the JavaScript I am trying to grab it with:</p>
  <pre><code>var all = document.getElementsByTagName('*'); 
  for (var i=0, max=all.length; i &lt; max; i++) 
  {
  var elem = all[i];
  if(elem.getAttribute(&quot;id&quot;) == 'ext-gen26'){
      if(elem.attributes != null){
          for (var x = 0; x &lt; elem.attributes.length; x++) {
              var attrib = elem.attributes[x];
              alert(attrib.name + &quot; = &quot; + attrib.value);  
          }
      }
  }
  };
  </code></pre>
  <p>It only comes back with the three attributes that are defined in the code.</p>
  <p><code>innerHTML</code>, <code>text</code>, and <code>textContent</code> - all come back as <code>null</code>.</p>