JavaScript中blur的用法是什么

JavaScript中blur的用法是什么,第1张

JavaScript中blur的用法是什么

JavaScript中blur的用法是“anchorObject.blur()”,blur是失去某个焦点的意思,多用在输入框input,失去焦点,光标有不会在那里了,不能够输入内容了。

本教程 *** 作环境:windows7系统、javascript1.8.5版、Dell G3电脑。

是失去某个焦点的意思,多用在输入框input,失去焦点,光标有不会在那里了,不能够输入内容了

相对的获取焦点就是focus

语法

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

【推荐学习:javascript高级教程】

以上就是JavaScript中blur的用法是什么的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/692992.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-04-22
下一篇2022-04-22

发表评论

登录后才能评论

评论列表(0条)

    保存