Printing value of button's data attribute in a table
<p>I have a table that gets printed with a HTML button on each row.  PHP is used to give each button a possibly different value in a data attribute that I have defined.</p>

<p>Once the whole table has been printed, I want to use some JQuery to print out a button's data attribute value when the user clicks.</p>

<p>Each button looks like this:</p>

<pre><code>&lt;button rel="test" data-myatt="hello world" id="myid"&gt;Click Me&lt;/button&gt;
</code></pre>

<p>The JQuery I have so far is this:</p>

<pre><code>$(document).ready(function () {
   $('#my_table').on('tr button[rel=test]').click(function() {
   alert($('#myid').data('myatt'));           
   });
 });
</code></pre>

<p>But when the buttons are clicked, I just get 'undefined' returned.</p>

<p><strong>EDIT:</strong> The undefined error has gone (thanks to @Shion) but now the value of the data attribute in the first row is printed regardless of which button is pressed.  </p>

<p>Any ideas?  Thank you.</p>
