JavaScript中blur的用法是什么


本文摘自PHP中文网,作者醉折花枝作酒筹,侵删。

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

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

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

相对的获取焦点就是focus

语法

1

anchorObject.blur()

实例

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

<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的用法是什么的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

js回调函数是什么

javascript怎么删除css样式

javascript怎么去掉字符

javascript:世界上最被误解的语言

javascript如何分割字符串

javascript怎么将字符串转为对象

javascript怎么设置元素宽度

javascript怎么开启

javascript数组什么意思

javascript怎么设置元素属性

更多相关阅读请进入《javascript》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...