Table删除所有行

1.用jquery的话,还是很简单的

$("#tbid").empty();

2.但如果要保留前几行,比如前两行的话

function ClearTableData(tbid){
	var rows = document.getElementById(tbid).getElementsByTagName('tr');
	if(rows==null || rows.length<3)return;
	for(var i=2;i<rows.length;i++)
	{
		rows[i].parentNode.removeChild(rows[i]);
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*