第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

以table為父節(jié)點(diǎn),創(chuàng)建子節(jié)點(diǎn)tr及tr子節(jié)點(diǎn)td。如何使鼠標(biāo)移動(dòng),對(duì)應(yīng)那一行背景顏色改變且每一塊td顏色不同

以table為父節(jié)點(diǎn),創(chuàng)建子節(jié)點(diǎn)tr及tr子節(jié)點(diǎn)td。如何使鼠標(biāo)移動(dòng),對(duì)應(yīng)那一行背景顏色改變且每一塊td顏色不同

where_i_go 2018-07-26 10:56:38
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title>表格添加與鼠標(biāo)移動(dòng)</title> <script type="text/javascript" >function tab(){ var pli=document.getElementById("first"); var sli=document.createElement("tr"); sli.innerHTML="<td >"+document.getElementById("input1").value+"</td>" +"<td >"+document.getElementById("input2").value+"</td>" +"<td ><p onclick='del(this)'>刪除</p></td>"; pli.appendChild(sli); document.getElementById("input1").value=""; document.getElementById("input2").value=""; }? ?function del(e){? ? var o=e.parentNode.parentNode ;? ? o .parentNode .removeChild(o);? ??}</script></head> <body> <p>在下面輸入框輸入標(biāo)題</p> <input id="input1" type="text" value="" > <p>在下面輸入框中輸入你想輸入的內(nèi)容</p> <textarea id="input2" name="" cols="30" rows="30" ></textarea> <input type="button" value="點(diǎn)我玩啊" onclick="tab()"> <table id="first" width="auto"; height="auto"; border="1"; cellspacing="0";> <tr> <th width="200px">標(biāo)題</th> <th width="500px">內(nèi)容</th> <th>操作</th> </tr> </table> </body></html>
查看完整描述

1 回答

已采納
?
qq_一米陽(yáng)光

TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超1個(gè)贊

<!DOCTYPE html>

<html>


<head>

<meta charset="utf-8" />

<title>表格添加與鼠標(biāo)移動(dòng)</title>

<script type="text/javascript">

function tab() {

var pli = document.getElementById("first");

var sli = document.createElement("tr");

sli.innerHTML = "<td>" + document.getElementById("input1").value + "</td>" +

"<td >" + document.getElementById("input2").value + "</td>" +

"<td ><p onclick='del(this)'>刪除</p></td>";

pli.appendChild(sli);

sli.onmouseenter = showColor;

sli.onmouseleave = hideColor;

document.getElementById("input1").value = "";

document.getElementById("input2").value = "";

}


function del(e) {

var o = e.parentNode.parentNode;

o.parentNode.removeChild(o);


}

var color = ['#4fbbfd', '#c9fd74', '#ff75ca'];


function showColor(e) {

var childNodes = e.target.childNodes;

for (var i = 0; i < childNodes.length; i++) {

childNodes[i].style.backgroundColor = color[i]

}

}


function hideColor(e) {

var childNodes = e.target.childNodes;

for (var i = 0; i < childNodes.length; i++) {

childNodes[i].style.backgroundColor = '#fff';

}

}

</script>

</head>


<body>

<p>在下面輸入框輸入標(biāo)題</p>

<input id="input1" type="text" value="">

<p>在下面輸入框中輸入你想輸入的內(nèi)容</p>

<textarea id="input2" name="" cols="30" rows="30"></textarea>

<input type="button" value="點(diǎn)我玩啊" onclick="tab()">

<table id="first" width="auto" ; height="auto" ; border="1" ; cellspacing="0" ;>

<tr>

<th width="200px">標(biāo)題</th>

<th width="500px">內(nèi)容</th>

<th>操作</th>

</tr>

</table>

</body>


</html>


看一下是否符合你的問(wèn)題?

查看完整回答
1 反對(duì) 回復(fù) 2018-07-26
  • where_i_go
    where_i_go
    初學(xué)的我只有一種方法也是借鑒的別人的,你這個(gè)給我開(kāi)啟了一些思路,謝謝了,哈哈
  • 1 回答
  • 0 關(guān)注
  • 1244 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)