鼠标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>

 

posted @ 2010-03-04 10:24  豪情  阅读(908)  评论(0编辑  收藏  举报