js 表格插入指定行

js在table指定tr行上或下面添加tr行

function onAddTR(trIndex) 
        { 
            var tb = document.getElementById("tb1"); 
            var newTr = tb.insertRow(trIndex);//添加新行,trIndex就是要添加的位置 
            var newTd1 = newTr.insertCell(); 
            newTd1.innerHTML = "这是新行,位置:" + trIndex; 
            var newTd2 = newTr.insertCell(); 
            newTd2.innerHTML = "这是新行,位置:" + trIndex; 
        } 

 

http://www.cnblogs.com/caicaizi/p/4952551.html

posted @ 2017-07-10 15:14  张主任好  阅读(2534)  评论(0编辑  收藏  举报