Focus / no focus (Blur)






<!DOCTYPE html>
<html>
<head>
<style>
a:focus, a:active {
color: green;
}
</style>
</head>
<body>

<a id="myAnchor" href="http://www.w3schools.com">Visit W3Schools.com</a>

<p>Click the buttons to give focus and/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>










( focusnofocusblur.html )- by Paolo Puglisi - Modifica del 17/12/2023