代码:
<body>
<input type="text" value="哈哈">
<script>
var text=document.querySelector('input');
text.onfocus=function(){
if (text.value=='哈哈'){
text.value=' ';
}
}
text.onblur=function(){
if(text.value==' '){
text.value='哈哈'
}
}
</script>
</body>
属性均为可读写。