如下所示:
复制代码代码如下:
<!Doctype HTML公共“ - // W3C // DTD XHTML 1.0 Transitional // en”“” http://www.org/tr/tr/xhtml1/dtd/xhtml1-xhtml1-transitional.transitional.dtdd'>
<html xmlns =“ http://www.w3.org/1999/xhtml”>
<头>
<meta http-equiv =“ content-type” content =“ text /html; charset = utf-8” />
<title>无标题文档</title>
<style type =“ text/css”>
.clearfieldblurred {
颜色:#ccc;
字体风格:斜体;
字体重量:正常;
宽度:150px;
}
.ClearFieldActive {
颜色:#4E4E4E;
字体重量:大胆;
宽度:150px;
}
</style>
<脚本类型=“ text/javascript”>
函数clearfiled(){
var bbb = document.getElementById(“ bbb”);
if(bbb.value ==“ bbb”){
bbb.value ='';
bbb.ClassName ='ClearFieldActive';
}
}
window.document.onmousedown = function(){
var bbb = document.getElementById('bbb');
if(bbb.value ==“”){
bbb.value ='bbb';
bbb.classname ='clearfieldblurred';
}
}
</script>
</head>
<身体>
<input type =“ text” id =“ aaa” value =“ aaa” onfocus =“ if(this.value =='aaa'){this.value =''; this.className ='clear fieldActive';} =“ if(this.value ==''){this.value ='aaa'; this.className ='clearfieldblurred';}/>
<br />
<输入type =“ text” id =“ bbb” value =“ bbb” onclick =“ clearfiled()” />
</body>
</html>