久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

js控制刪除table的行

 韻朵之家 2009-05-07

<html>
<head>
<script language="javascript">
var r=-1;
function addrow(){
r++;
//alert(r);
var tbody = document.getElementById("tb");
var row = tbody.insertRow();

        var innerHTML1 = "<input type='text' name='cusername' size='15' value=''>";
         var innerHTML2 = "<input type='text' name='cpassword' size='15' value=''>";
   var innerHTML3 = "<input type='button' name='cpassword2' value='刪除' onclick='remove("+r+")'>";
    row.insertCell(0).innerHTML = innerHTML1;
          row.insertCell(1).innerHTML = innerHTML2;
    row.insertCell(2).innerHTML = innerHTML3;
   tbody.appendChild(row);

}
function remove(ind){

//alert(ind);

var tbody = document.getElementById("tb");
r--;
    var oTr = tbody.childNodes[ind];
   // alert(tbody.childNodes.length);
   // alert(oTr.tagName);
   //alert(oTr.innerHTML);

   tbody.removeChild(oTr);
    var trRows = tbody.childNodes;
    for (var i = ind; i < trRows.length; i++) {
        var sibingTr = trRows[i];
        //alert(sibingTr.innerHTML);
        if (sibingTr == null) {
            continue;
        }
        var cells = sibingTr.childNodes;
        for (var j = 0; j < cells.length; j++) {
            var oldContent = cells[j].innerHTML;
             if (j == 0) {
                var replaceRegx = "(\d+)/g";
                oldContent = oldContent.replace(replaceRegx, "" + (i + 1));
            }
            cells[j].innerHTML = ProcessStrIndex(oldContent, i);
        }
        //alert(sibingTr.innerHTML);
    }
}

function ProcessStrIndex(str, index) {
//alert(index);
   var replaceRegx = /\(\d+\)/g;
    str = str.replace(replaceRegx, "(" + index + ")");
    replaceRegx = /\[\d+\]/g;
    str = str.replace(replaceRegx, "[" + index + "]");
    return str;
}
</script>
</head>
<table border = "1" width="55%">
<tbody id = "tb">
<thead><td colspan = "3">addAndRemoveRows</td></thead>
</tbody>
<tr align = "left"><td align = "right" colspan="3"><input type="button" value="添加" onclick="addrow()"/></td></tr>
</table>
</html>

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多