-
onfocus
鎖定
- 中文名
- onfocus
- 外文名
- onfocus
onfocus語法
onfocus參數
在onfocus事件發生時,"SomeJavaScriptCode"是必需執行的JavaScript。
onfocus實例
在本例中,當輸入框獲得焦點(光標)時,其背景顏色將改變:
onfocus代碼
<html> <head> <script type="text/javascript"> function setStyle(x) { document.getElementById(x).style.background="yellow" } </script> </head> <body> First name: <input type="text" onfocus="setStyle(this.id)" id="fname"> <br /> Last name: <input type="text" onfocus="setStyle(this.id)" id="lname"> </body> </html>