Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <style> a:focus, a:active { color: green; } </style> </head> <body> <a id="myAnchor" href="http://www.w3big.com">访问本教程</a> <p>点击按钮设置或移除以上链接的焦点。</p> <input type="button" onclick="getfocus()" value="获取焦点"> <input type="button" onclick="losefocus()" value="移除焦点"> <script> function getfocus() { document.getElementById("myAnchor").focus(); } function losefocus() { document.getElementById("myAnchor").blur(); } </script> </body> </html>