What is blur() Method in HTML

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

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

<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>

Source: www.w3schools.com

Leave a Comment