摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>事件</title> </head> <body> <!-- HTML 事件觸發(fā)瀏覽器中的動(dòng)作(action),比如當(dāng)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>事件</title> </head> <body> <!-- HTML 事件觸發(fā)瀏覽器中的動(dòng)作(action),比如當(dāng)用戶(hù)點(diǎn)擊某個(gè) HTML 元素時(shí)啟動(dòng)一段 Javascript 代碼。 下面是一個(gè)屬性列表,這些屬性可插入 HTML 標(biāo)簽來(lái)定義事件動(dòng)作 屬性 描述 onfocus 元素或得焦點(diǎn) onblur 元素失去焦點(diǎn) onchange 域的內(nèi)容被改變 onclick 當(dāng)用戶(hù)點(diǎn)擊某個(gè)對(duì)象時(shí)調(diào)用的事件句柄 ondblclick 當(dāng)用戶(hù)雙擊某個(gè)對(duì)象時(shí)調(diào)用的事件句柄 onkeydown 某個(gè)鍵盤(pán)按鍵被按下 onkeyup 某個(gè)鍵盤(pán)按鍵被松開(kāi) onkeypress 某個(gè)鍵盤(pán)按鍵被按下并松開(kāi) onload 一張頁(yè)面或一副圖像完成加載 onmousedown 鼠標(biāo)按鈕被按下 onmousemove 鼠標(biāo)被移動(dòng) onmouseout 鼠標(biāo)從某元素移開(kāi) onmouseover 鼠標(biāo)移動(dòng)到某元素之上 onmouseup 鼠標(biāo)按鍵被松開(kāi) onsubmit 確認(rèn)按鈕被點(diǎn)擊 --> <script> function myFocus(x) { x.style.background = 'red'; } function myonclick(y) { y.style.borderRadius = '50px'; y.style.background = 'pink'; } function divOnmouseover(z) { z.style.background = 'red'; } function divOnmouseout(x) { x.style.background = '#fff'; } </script> 姓名:<input type="text" onfocus ="myFocus(this)"> <br><br> <div style="width: 100px;height: 100px;border: 1px solid #ccc;" onclick="myonclick(this)"></div> <hr> <div style="width: 600px;height: 200px;border: 1px solid red;" onmouseover="divOnmouseover(this)" onmouseout="divOnmouseout(this)"></div> </body> </html>
批改老師:滅絕師太批改時(shí)間:2019-01-06 12:34:30
老師總結(jié):完成的不錯(cuò),常用是事件方法也就那么幾個(gè),要熟練運(yùn)用