Grab text contained within PHP-generated element
<p>I'm having trouble grabbing the actual text within a header tag that is generated by some PHP code. Here's the portion of the page that I'm grabbing.</p>

<pre><code>&lt;div class="container"&gt;
  &lt;div class="majorContainer"&gt;
    &lt;h2&gt;Your results for: &lt;small&gt;"tables"&lt;/small&gt;&lt;/h2&gt;
    &lt;hr /&gt;
    &lt;div class='accordionButton'&gt;
      &lt;h3 style="display:inline"&gt;1. &lt;/h3&gt;
      &lt;h3 style="display:inline" id='major-1'&gt;Electrical Engineering Technology&lt;/h3&gt;
      &lt;p&gt;...&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class='accordionButton'&gt;
      &lt;h3 style="display:inline"&gt;2. &lt;/h3&gt;
      &lt;h3 style="display:inline" id='major-2'&gt;Retail Management&lt;/h3&gt;
      &lt;p&gt;...&lt;/p&gt;
    &lt;/div&gt;
</code></pre>

<p>Basically, when the user clicks on an 'accordionButton', I want to pull the text from the header tag of that specific button. In my PHP, I assigned an ID to each header tag because I figured I could just pull the text doing:</p>

<pre><code>document.getElementById(this.getElementsByTagName("h3")[0].id).text
</code></pre>

<p>When I alerted this in a message box, I'm only seeing 'undefined'. I tried, instead, just doing...</p>

<pre><code>$(this).text()
</code></pre>

<p>...but this returned "1. Electrical Engineering Technology..." which is not what I want. I just want the title "Electrical Engineering Technology" that is contained in the h3 tag.</p>

<p>What am I doing wrong? Thanks!</p>
