JavaScript光标失焦事件(onblur)
光标失焦事件(onblur)
onblur事件与onfocus是相对事件,当光标离开当前获得聚焦对象的时候,触发onblur事件,同时执行被调用的程序。
下面例子,当光标离开时,让用户确认是否已经输入信息:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>php.cn</title>
<script>
function fun(){
window.alert("请确认这是您的真实姓名")
}
</script>
</head>
<body>
<form>
姓名:
<input name="username" type="text" value="请输入姓名" onblur="fun()" >
</form>
</body>
</html>

落花微雨
继续学习
7年前 添加回复 0