0
I would like to take the value of one column of the table, but in a way that I could reuse the function to take values from other tables.
I tried it this way, but it does not present me anything on the console.
OBS: The value for line only.
HTML
<table class="table">
<thead></thead>
<tbody class="table-hover">
<tr>
<td id="id">2</td><td>Cliente N - 1</td>
<td>teste</td>
<td>2017-02-14 22:00:52</td>
<td class="txt-center pointer"><span class="glyphicon glyphicon-ok txt-error pointer" onclick="updateStatus()"></span></td>
</tr>
<tr>
<td id="id">3</td>
<td>Cliente N - 2</td>
<td>teste</td>
<td>2017-02-14 22:00:52</td>
<td class="txt-center pointer"><span class="glyphicon glyphicon-ok txt-error pointer" onclick="updateStatus()"></span></td>
</tr>
</tbody>
<tfoot></tfoot>
jQuery
function updateStatus(param){ //param seria o numero da coluna
var teste = $('table > tbody').closest('tr').find('td').eq(param).text();
console.log(teste);
}
then through the param I would indicate the column to be picked up the value...
You need a specific line or all of them?
– Woss
Sorry, I will complete the question.
– Max Rogério
"The line" would only be the first or second line?
– Woss
In case I would click on
span
where this the function and then in that row it would pick up the value of the column, the column would be passed through theparam
, for example in column 3 where the date isparam
would indicate the column where this column q contains date.– Max Rogério
I’m sorry, I didn’t see that there was a call from function on
span
.– Woss
Maybe what you need is in the answer to that other question : question
– Diego Ramos