執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <style> a:focus, a:active { color: red; } </style> <body> <h1>The Element Object</h1> <h2>The focus() and blur() Methods</h2> <a id="myAnchor" href="https://w3schools.tw">Visit W3Schools.com</a> <p>Click the buttons to give or remove focus from the link above.</p> <input type="button" onclick="getfocus()" value="Get focus"> <input type="button" onclick="losefocus()" value="Lose focus"> <script> function getfocus() { document.getElementById("myAnchor").focus(); } function losefocus() { document.getElementById("myAnchor").blur(); } </script> </body> </html>