Reputation: 105
I am trying to add rows to my repeater using jQuery using below script.It is working perfect in IE, but not in Firefox, Chrome and Safari.
looks like issue with using of outerHTML. Can someone help me?
function AddRowToTable(table) {
var newRow1 = $(table.rows[table.rows.length - 2].outerHTML);
var myRow = $(table.rows[table.rows.length - 2]);
$(myRow).after(newRow1);
}
Upvotes: 0
Views: 650
Reputation: 58385
Possible duplicate of Add table row in jQuery
The solution was
$('#myTable tr:last').after('<tr>...</tr><tr>...</tr>');
You can probably modify that to being useful in your case...
Upvotes: 0
Reputation: 237845
outerHTML
is a proprietary standard, unsupported by browsers other than IE. It's a bad idea anyway -- you should almost always just use the DOM nodes and clone them where necessary. Fortunately, jQuery makes this very easy for you.
function AddRowToTable(table) {
var $table = $(table);
var $oldRow = $table.find('tr').eq(-2); // get the second last row
var $newRow = $oldRow.clone(true); // clone the node
$oldRow.after($newRow); // insert the new row after the old row
}
See:
Upvotes: 1