grab selected table row data (skip first td element) before deleting
Hi all
I am following some tutorials and working on this one right now :
I would like to grab selected table row data (skip first td element) before deleting the selected row.
- $(".delete-row").click(function(){
$("table tbody").find('input[name="record"]').each(function(){
if($(this).is(":checked")){
$(this).parents("tr").remove();
}
});
});
I am able to alert the data in a row so far :
- $(".delete-row").click(function(){
$("table tbody").find('input[name="record"]').each(function(){
if($(this).is(":checked")){
$(this).closest('tr').find('td').each(function() {
var textval = $(this).text(); // this will be the text of each <td>
alert(textval);
});
$(this).parents("tr").remove();
}
});
});
*** I've managed to find out how to skip the first td :
- $(".delete-row").click(function(){
$("table tbody").find('input[name="record"]').each(function(){
if($(this).is(":checked")){
$(this).closest('tr').find('td:not(:first)').each(function() {
var textval = $(this).text(); // this will be the text of each <td>
alert(textval);
});
$(this).parents("tr").remove();
}
});
});
But now I would like to save the row data in a var with each value separated by spaces.
Something like this :
var textval = value1 value
Instead of the variable just holding a single value as it does now.
Must this be done using a loop or is there another way of doing this ?
I would appreciate a few tips/pointers for this.
Thank you
Den