陪你做好前端设计!
源代码:
点击运行
<!DOCTYPE html> <html> <head> <style> a:focus, a:active { color: green; } </style> </head> <body> <a id="myAnchor" href="http://www.runoob.com">访问素材8网教程</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>
运行结果