I would like to add table row to my table body, which I can achieve with this code:
var tr = $('<tr/>');
$('#myTable > tbody:last').append(tr);
However some pages could have too many rows and hence I create dynamically a paginator in the last row.
In those cases if I used the code above the new tr would be appended below the paginator, which isn’t nice.
My paginator tr has the id <tr id="paginator_tr"> I wonder if I could alter this code
$('#myTable > tbody:last').append(tr);
with a condition to check if the last tr has the id = "paginator_tr" if so, then add the new row before that paginator row. Otherwise simply append the new row as the last row.
Are conditionals like this possible in jquery?
You can use
beforemethod if the paginator element exists otherwise you can append the tr element.