onblur和onfocus的区别

运行一下这个例子就知道区别是啥了!
< html >
 
< head >
< meta  http-equiv = "Content-Type"  content = "text/html; charset=gb2312" >
< title >新建网页 5</ title >
< script >
function aaa(obj){
if(typeof(obj.hasblur)=='undefined'){
alert("鼠标操作");
}else{
alert("键盘操作");
}
}
 
function bbb(obj){
if(event.keyCode==9){
obj.hasblur = true;
}
}
function ccc(obj){
obj.removeAttribute("hasblur");
}
</ script ></ head >
 
< body >
< input  id = t  type = text  value = ""  onblur = "aaa(this)"  onkeydown = "bbb(this)"  onfocus = "ccc(this)" >
</ body >
 
</ html >

你可能感兴趣的:(onblur和onfocus的区别)