定义与用法
The focus() method is used to give focus to a link.
使用focus() 方法可以聚焦到某个连接
语法
举例
<html> <head> <style type="text/css"> a:active {color:green} </style> <script type="text/javascript">
function getfocus() {document.getElementById('myAnchor').focus()} function losefocus() {document.getElementById('myAnchor').blur()} </script> </head> <body> <a id="myAnchor" href="http://www.ruanchen.com">访问 ruanchen.com</a>
<br /><br/> <input type="button" onclick="getfocus()" value="Get focus"> <input type="button" onclick="losefocus()" value="Lose focus">
</body> </html> |
尝试与演示
Using focus() and blur()
使用focus()和blur()