HTML DOM blur() 方法

定义和用法

blur() 方法用于从链接上移开焦点。

语法

anchorObject.blur()

实例

<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="https://www.layui1.com">Visit www.layui1.com</a>
<br /><br/>
<input type="button" onclick="getfocus()" value="Get focus">
<input type="button" onclick="losefocus()" value="Lose focus">
</body>

</html>