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

What is the usage of blur in JavaScript?

醉折花枝作酒筹
Release: 2023-01-07 11:45:01
Original
7800 people have browsed it

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()
Copy after login

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>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template