Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting the table row values with jquery
    text
    copied!<p>Hi guys I have a simple problem im trying to get the values from an html table row. son when i click on the table row delete button i want to put those values on variables to send to the server. I have found something from here <a href="http://jsbin.com/ihaqe6" rel="noreferrer">http://jsbin.com/ihaqe6</a> that looks like what i need but when i put it together for my scenario it does not work. </p> <p>here is the table html.</p> <pre><code> &lt;table id='thisTable' class='disptable' style='margin-left:auto;margin-right:auto;' &gt; &lt;tr&gt; &lt;th&gt;Fund&lt;/th&gt; &lt;th&gt;Organization&lt;/th&gt; &lt;th&gt;Access&lt;/th&gt; &lt;th&gt;Delete&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='fund'&gt;100000&lt;/td&gt;&lt;td class='org'&gt;10110&lt;/td&gt;&lt;td&gt;OWNED&lt;/td&gt;&lt;td&gt;&lt;a class='delbtn'ref='#'&gt;X&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td class='fund'&gt;100000&lt;/td&gt;&lt;td class='org'&gt;67130&lt;/td&gt;&lt;td&gt;OWNED&lt;/td&gt;&lt;td&gt;&lt;a class='delbtn' href='#'&gt;X&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td class='fund'&gt;170252&lt;/td&gt;&lt;td class='org'&gt;67130&lt;/td&gt;&lt;td&gt;OWNED&lt;/td&gt;&lt;td&gt;&lt;a class='delbtn' href='#'&gt;X&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td class='fund'&gt;100000&lt;/td&gt;&lt;td class='org'&gt;67150&lt;/td&gt;&lt;td&gt;PENDING ACCESS&lt;/td&gt;&lt;td&gt;&lt;a class='delbtn' href='#'&gt;X&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td class='fund'&gt;100000&lt;/td&gt;&lt;td class='org'&gt;67120&lt;/td&gt;&lt;td&gt;PENDING ACCESS&lt;/td&gt;&lt;td&gt;&lt;a class='delbtn' href='#'&gt;X&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>and here is the jquery.</p> <pre><code> var tr = $('#thisTable').find('tr'); tr.bind('click', function(event) { //var values = ''; // tr.removeClass('row-highlight'); var tds = $(this).addClass('row-highlight').find('td'); $.each(tds, function(index, item) { values = values + 'td' + (index + 1) + ':' + item.innerHTML + '&lt;br/&gt;'; alert(values); }); alert(values); }); </code></pre> <p>what am I doing wrong? I keep looking at examples but I cant seem to make this work.</p> <p>Miguel</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload