導航:首頁 > 編程語言 > jsremovechild沒效果

jsremovechild沒效果

發布時間:2024-09-06 02:33:04

js動態添加tr,刪除checkbox選中的行

function del(){
var tab=document.getElementById('HRSTable');
for(var i=tab.rows.length-1;i>0;i--){
if(tab.rows[i].cells[0].getElementsByTagName('input')[0].checked){
tab.deleteRow(i);
}
}
}

❷ 這段js代碼為什麼會不能實現呢麻煩高手給看看

錯誤

A : 循環變數復用, 外層循環都用了i了, 你里層循環為什麼還用i

B : 邏輯錯誤, myDiv是個什麽鬼, 從doc上查找#myDiv然後每次添加到#input?

很明顯你想表達myDiv每次循環生成div然後appendChild

C : 元素標簽錯誤, #input怎麽也不應該是table吧, 用table就好好寫tbody, tr和td啊

附上簡單修改版

<inputtype="text"id="js_add_num"name="js_add_num"size="4"onkeyup="addtextarea(this.value)"/>
<script>
functionaddtextarea(x){
if(x==""){
count=0;
}else{
count=x;
}
varinputs=document.getElementById("inputs");
while(inputs.hasChildNodes())
{
inputs.removeChild(inputs.firstChild);
}
for(varn=0;n<count;n++){
varusername=document.createElement("input");
varinfo=document.createElement("span");
varformat=document.createElement("span");
info.innerHTML="姓名:";
username.type="text";
username.name="name[]";
username.id=n;
inputs.appendChild(info);
inputs.appendChild(username);

vararray=["男","女"];
varselectList=document.createElement("select");
varinfo=document.createElement("span");
selectList.id="mySelect";
selectList.name="sex[]";
info.innerHTML="性別:";
inputs.appendChild(info);
inputs.appendChild(selectList);
for(vari=0;i<array.length;i++){
varoption=document.createElement("option");
option.value=array[i];
option.text=array[i];
selectList.appendChild(option);
}
inputs.appendChild(document.createElement("br"));
}
}
</script>
<divid="inputs"></div>
閱讀全文

與jsremovechild沒效果相關的資料

熱點內容
p190文件用什麼打開 瀏覽:252
怎麼修改ps簽署文件 瀏覽:847
怎麼找到編程貓作品文件 瀏覽:647
鐵路局的網站是多少 瀏覽:194
微信雙號 瀏覽:926
招標文件中的凈值是什麼意思 瀏覽:675
有哪些app能借出5000 瀏覽:250
編程語言哪個發展好 瀏覽:974
刪除xp密碼 瀏覽:974
手機怎麼在word製作作業文件 瀏覽:489
工行銀行卡安全升級 瀏覽:807
桌面放的文件找不到 瀏覽:922
買學生票用什麼app 瀏覽:590
共建共享網路平台 瀏覽:39
js傳值到超鏈接裡面 瀏覽:608
編程中的w和h是什麼 瀏覽:313
資料庫切了什麼意思 瀏覽:213
如何登錄極路由器設置密碼 瀏覽:522
jsp用戶登陸密碼加密源代碼 瀏覽:629
everfilter使用教程 瀏覽:768

友情鏈接