I have an HTML table(Dynamic) and a save/edit button on each row. On clicking save, the values needs to be collected to jQuery variables and AJAX POSTed to a PHP page. I am able to retrieve the values in 3 Table cells, but being a CSS counter, I am not able to get the value of the Sl:No column. It is important that I get this number.
HTML TABLE
<tr role="row" class="odd">
<td contenteditable="false" class="sorting_1"><span class="sl"> </span> </td>
<td contenteditable="false"> <span class="name">Alex Nilson </span></td>
<td contenteditable="false"><span class="price"> 1234 </span></td>
<td contenteditable="false"> <span class="qty">1234 </span></td>
<td><button class="pr_edit" href="javascript:;"> Edit </button></td>
<td><button class="pr_elete" href="javascript:;"> Delete </button></td>
</tr>
The jQuery function is as follows.
$('#sample_editable_1').on('click', '.pr_edit', function() {
var currentTD = $(this).parents('tr').find('td');
var ino = $(this).closest('tr').find("span.sl").text();
var iname = $(this).closest('tr').find("span.name").text();
var iprice = $(this).closest('tr').find("span.price").text();
var iqty = $(this).closest('tr').find("span.qty").text();
});
Following is the CSS code. #sample_editable_1 is the name of the table.
#sample_editable_1 tbody {
counter-reset: tablerow;
}
#sample_editable_1 .sorting_1::before {
counter-increment: tablerow;
content: counter(tablerow)". ";
}
It all works perfectly except the following trouble.
- The sl span is a CSS counter. I am not being able to retrieve the value of this SPAN.