如下所示 :
复制代码代码如下:
<! DocType html public "-// w3c // dtd xhtml 1.0 Transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transicional.dtd ">
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> 无标题文档 </title>
<style type = "text/css">
.clearfieldblurred {
Color: #ccc;
estilo de fuente: cursiva;
Font-peso: Normal;
Ancho: 150px;
}
.ClearfieldActive {
Color:#4e4e4e;
Font-Weight: Bold;
Ancho: 150px;
}
</style>
<script type = "text/javaScript">
función 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>
</ablo>
<Body>
<input type = "text" id = "aaa" valor = "aaa" onfocus = "if (this.Value == 'aaa') {this.value = ''; this.classname = 'clearFieldActive';}" Onblur = "if (this.value == '') {this.value = 'aaa'; this.classname = 'clearFieldblurred';}"/>
<Br />
<input type = "text" id = "bbb" value = "bbb" onClick = "clearFileD ()" />
</body>
</html>