<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="../default.htm">Visit W3Schools.com</a> <br /><br/> <input type="button" onclick="getfocus()" value="Get focus"> <input type="button" onclick="losefocus()" value="Lose focus"> </body> </html>
Your Result:
Edit the code above and click to see the result.
W3Schools.com
- Try it yourself