Javascript DOM HTML Input Button handle click event

Description

Javascript DOM HTML Input Button handle click event

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
a:focus, a:active {
  color: green;
}
</style>// w  ww  .j a v a 2 s  . com
</head>
<body>

<a id="myAnchor" href="https://www.java2s.com">Visit java2s.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>
</html>



PreviousNext

Related