導航:首頁 > 編程語言 > 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沒效果相關的資料

熱點內容
專題學習網站源碼 瀏覽:163
jsphead什麼 瀏覽:88
gps串口數據怎麼發送 瀏覽:968
win10文件主頁共享查看 瀏覽:411
中國聯通有哪些app是免流的 瀏覽:176
邊做邊保存的文件找不到了 瀏覽:858
win10照片應用文件夾名稱 瀏覽:966
編程如何解決資金的原子性 瀏覽:638
如何製作廣角鏡頭矯正文件 瀏覽:513
在網頁開發中應該選用哪個資料庫 瀏覽:742
iphone5移動卡貼 瀏覽:990
電腦文件的格式 瀏覽:127
extjs的xtype 瀏覽:959
suse11iso文件要u盤安裝 瀏覽:153
如何將報表統計數據轉化為圖形 瀏覽:444
如何寄快遞材料文件 瀏覽:265
java構造方法private 瀏覽:475
手機文件找回恢復 瀏覽:516
word怎麼把u盤里的文件拔掉 瀏覽:976
港版蘋果用的插排 瀏覽:1000

友情鏈接