Tuesday, July 9, 2013

Inserting and Removing Table Row

To insert a row to table:
function themdong(idbang, iddongcu, iddongmoi, idocu, idomoi){
dongmoi=$('#'+idbang+' tr:last').clone();
dongmoi.appendTo('#'+idbang);

//modify new row's attribute: 
$('#'+idbang).find('tr:last').attr('id', function(index, id) {
return id.replace(iddongcu, iddongmoi);
});

//modify new cell's attribute: 
dongmoi.find('td').attr('id', function(index, id) {
return id.replace(idocu, idomoi);
});
}

To remove a row from table:

0 comments:

Post a Comment