如下所示:
复制代码代码如下:
<!doctype html public " - // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<Meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title>无标题文档</title>
<style type = "text/css">
.ClearFieldBlurred {
色:#ccc;
フォントスタイル:イタリック;
font-weight:正常;
幅:150px;
}
.ClearFieldactive {
色:#4e4e4e;
font-weight:bold;
幅:150px;
}
</style>
<script type = "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>
<body>
<入力型= "text" id = "aaa" value = "aaa" onfocus = "if(this.value == 'aaa'){this.value = ''; this.classname = 'clearfieldactive';}" onblur = "if(this.value == ''){this.value = 'aaa'; this.classname = 'clearfieldblurred';}"/>
<br />
<入力型= "text" id = "bbb" value = "bbb" onclick = "clearfiled()" />
</body>
</html>