I want to delete a row when i click the glyphicon-trash. I tried many ways but still cant get row index properly.
<table class="table table-bordered" id="table_GemList">
<thead>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</thead>
<tbody id="GemListBody">
<tr>
<td>Oval</td>
<td>Red</td>
<td>2.23</td>
<td><span class="glyphicon glyphicon-trash"></span></td>
</tr>
<tr>
<td>Box</td>
<td>Pink</td>
<td>2.23</td>
<td><span class="glyphicon glyphicon-trash"></span></td>
</tr>
</tbody>
</table>
---------- My code
$(document).on("click", ".glyphicon-trash", function () {
var d = $(this).parentNode.parentNode.rowIndex;
document.getElementById("table_GemList").deleteRow(d);
});