摘要:<!DOCTYPE html> <html> <head> <title>事件作業(yè)</title> </head> <body> <script type="text/javascript"> //
<!DOCTYPE html> <html> <head> <title>事件作業(yè)</title> </head> <body> <script type="text/javascript"> // onfocus 元素獲得焦點(diǎn)。 function myfovus(x) { x.style.background="blue" } function myfovus2(y) { y.style.background="red" } </script> <!-- onfocus對(duì)div無效,無法再div中獲取焦點(diǎn) --> <div style="width: 100px;height: 100px;border: 1px solid #ccc; background: pink;" onfocus="myfovus(this)"> <input type="" name="" onfocus="myfovus2(this)" > </div> <script type="text/javascript"> // onblur 元素失去焦點(diǎn)。 function myonblur(x) { x.style.background="blue" } function myonblur1(y) { y.style.background="red" } </script> <!-- onblur對(duì)div無效 --> <!-- onfocus對(duì)input生效 --> <div style="width: 100px;height: 100px;border: 1px solid #ccc; background: pink;" onblur="myonblur(this)"> <input type="" name="" onblur="myonblur1(this)"> </div> <script type="text/javascript"> // onchange 域的內(nèi)容被改變。 function myonchange(x) { x.style.background="blue" } function myonchange1(y) { y.style.background="red" } </script> <!-- 當(dāng)文本域中的更改后,div和input的狀態(tài)改變 --> <div style="width: 100px;height: 100px;border: 1px solid #ccc; background: pink;" onchange="myonchange(this)"> <input type="" name="" onchange="myonchange1(this)"> </div> <script type="text/javascript"> // onclick 當(dāng)用戶點(diǎn)擊某個(gè)對(duì)象時(shí)調(diào)用的事件句柄。 function myonclick(x) { x.style.background="blue" } function myonclick1(y) { y.style.background="red" } </script> <div style="width: 100px;height: 100px;border: 1px solid #ccc; background: pink;" onclick="myonclick(this)"> <input type="" name="" onclick="myonclick1(this)"> </div> <script type="text/javascript"> // ondblclick 當(dāng)用戶雙擊某個(gè)對(duì)象時(shí)調(diào)用的事件句柄。 function myondblclick(x) { x.style.background="blue" } function myondblclick1(y) { y.style.background="red" } </script> <div style="width: 100px;height: 100px;border: 1px solid #ccc; background: pink;" onclick="myondblclick(this)"> <input type="" name="" onclick="myondblclick1(this)"> </div> </div> </body> </html>
批改老師:天蓬老師批改時(shí)間:2018-12-08 17:27:50
老師總結(jié):現(xiàn)代網(wǎng)頁,全是基于事件驅(qū)動(dòng)的,這與操作系統(tǒng)非常像, 事件很重要也很有意思