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的用法是什么的详细内容。