鼠标onfocus或onblur效果

onfocus onblur
   
     
< input type = " text " name = "" value = " 我是一个兵 " id = " test " / >

< script type = " text/javascript " >
var test = document.getElementById( " test " );
test.onfocus
= function (){ if ( this .value == this .defaultValue) this .value = "" ;}
test.onblur
= function (){ this .value = this .value == 0 ? this .defaultValue : this .value;}
< / script>

 

你可能感兴趣的:(focus)