首页 > 代码库 > js给文本框增加默认值

js给文本框增加默认值

<script type="text/javascript">
window.onload = function () {
var ss = document.getElementById("txt");
ss.onfocus = function () {
this.valuehttp://www.mamicode.com/= "";
ss.style.color = "black";
}
ss.onblur = function () {
if (this.value.length == 0) {
this.valuehttp://www.mamicode.com/= "请输入搜所内容";
ss.style.color = "Gray";
}
}
}
</script>

js给文本框增加默认值