DOM: how to delete table row(s)


delete first row:

function deleteFirstRow(tableId){
     var table = document.getElementById('tableId');
     table.deleteRow(0);
}

delete last row:

function deleteLastRow(tableId){
     var table = document.getElementById('tableId');
     table.deleteRow(table.rows.length - 1);
}

delete all rows:

function deleteAllRows(tableId){
     var table = document.getElementById('tableId');
     while (table.rows.length > 0){
		table.deleteRow(table.rows.length - 1);
     }
}
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • BlinkList
  • blogmarks
  • DZone
  • E-mail this story to a friend!
  • LinkaGoGo
  • Live
  • MisterWong
  • MisterWong.DE
  • Reddit
  • StumbleUpon
  • Technorati
  • ThisNext
  • Tumblr

Related posts:

  1. DOM:how to remove select options

Leave a Reply


wp