Home >Web Front-end >JS Tutorial >What is the usage of blur in JavaScript?

What is the usage of blur in JavaScript?

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-07-22 14:37:067775browse

The usage of blur in JavaScript is "anchorObject.blur()". Blur means losing a certain focus. It is mostly used in input boxes. If the focus is lost, the cursor will no longer be there, and content cannot be input. .

What is the usage of blur in JavaScript?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

means losing a certain focus. It is mostly used in input boxes. If the focus is lost, the cursor will no longer be there and the content cannot be entered.

The relative focus is focus

Grammar

anchorObject.blur()

Examples

<html>
<head>
<style type="text/css">
a:active {color:green}
</style>

<script type="text/javascript">
function getfocus()
{document.getElementById(&#39;myAnchor&#39;).focus()}

function losefocus()
{document.getElementById(&#39;myAnchor&#39;).blur()}
</script>
</head>

<body>
<a id="myAnchor"
href="http://www.w3school.com.cn">Visit W3School.com.cn</a>
<br /><br/>
<input type="button" onclick="getfocus()" value="Get focus">
<input type="button" onclick="losefocus()" value="Lose focus">
</body>

</html>

[Recommended learning: javascript advanced tutorial

The above is the detailed content of What is the usage of blur in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn