focus() 和blur()用法

  1. <html>  
  2. <head>  
  3.     <title>focus()和blur()用法</title>  
  4.     <style type="text/css">  
  5.         a:active  
  6.         {  
  7.             color: green;  
  8.         }  
  9.     </style>  
  10.   
  11.     <script type="text/javascript">  
  12.         function getfocus()  
  13.         {  
  14.             document.getElementById('myAnchor').focus() //获得焦点  
  15.         }  
  16.   
  17.         function losefocus()  
  18.         {  
  19.             document.getElementById('myAnchor').blur() //失去焦点  
  20.         }  
  21.     </script>  
  22.   
  23. </head>  
  24. <body>  
  25.     <a id="myAnchor" href="http://buliangniu.iteye.com">不良牛 buliangniu.iteye.com</a>  
  26.     <br />  
  27.     <br />  
  28.     <input type="button" οnclick="getfocus()" value="获得焦点" />  
  29.     <input type="button" οnclick="losefocus()" value="失去焦点" />  
  30. </body>  
  31. </html>  
  32. focus():取得表单域的焦点;
    blur():失去表单域的焦;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值