abstract:HTML代碼 <!DOCTYPE html><html><head><meta charset="UTF-8"><title>JavaScript核心篇事件</title><style>div {height: 400px;width: 600px;margin: 0 auto;fon
HTML代碼
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JavaScript核心篇事件</title>
<style>
div {height: 400px;width: 600px;margin: 0 auto;font-size: 16px;}
table,table tr th,table tr td { border:1px solid #000;}
table {border-collapse: collapse;}
table tr{height: 30px;line-height: 30px;text-align: center;}
</style>
</head>
<body>
<script type="text/javascript">
function changecolor(x) {
x.style.background="pink"
}
function changecolorr(y) {
y.style.background="#fff"
}
</script>
<div>
<table>
<thead>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<th colspan="3">JavaScript核心篇事件知識(shí)點(diǎn)</th>
</tr>
</thead>
<tbody>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>序號(hào)</td>
<td>屬性</td>
<td>描述</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>1</td>
<td>onfocus</td>
<td>元素獲得焦點(diǎn)</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>2</td>
<td>onblur</td>
<td>元素失去焦點(diǎn)</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>3</td>
<td>onchange</td>
<td>域的內(nèi)容被改變</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>4</td>
<td>onclick</td>
<td style="width:350px;">當(dāng)用戶點(diǎn)擊某個(gè)對(duì)象時(shí)調(diào)用的時(shí)間句柄</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>5</td>
<td>ondblclick</td>
<td>當(dāng)用戶雙擊某個(gè)對(duì)象時(shí)調(diào)用的事件句柄</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>6</td>
<td>onkeydown</td>
<td>某個(gè)鍵盤按鍵被按下</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>7</td>
<td>onkeypress</td>
<td>某個(gè)鍵盤按鍵被被按下并松開</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>8</td>
<td>onkeyup</td>
<td>某個(gè)鍵盤按鍵松開</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>9</td>
<td>onload</td>
<td>一張頁面或衣服圖像完加載</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>10</td>
<td>onmousedown</td>
<td>鼠標(biāo)按鈕被按下</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>11</td>
<td>onmousemove</td>
<td>鼠標(biāo)被移動(dòng)</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>12</td>
<td>onmouseout</td>
<td>鼠標(biāo)從某元素移開</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>13</td>
<td>onmouseover</td>
<td>鼠標(biāo)移到某元素之上</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>14</td>
<td>onmouseup</td>
<td>鼠標(biāo)按鍵被松開</td>
</tr>
<tr onmouseover="changecolor(this)" onmouseout="changecolorr(this)">
<td>15</td>
<td>onsubmit</td>
<td>確認(rèn)按鈕被點(diǎn)擊</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Correcting teacher:天蓬老師Correction time:2018-12-27 15:47:50
Teacher's summary:如果僅僅是實(shí)現(xiàn)鼠標(biāo)懸停變色, 使用js事件, 不如使用css中的hover偽類啦,你說呢?