js给文本框增加默认值

js给文本框增加默认值

 

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

posted @ 2014-11-15 21:56  WH帅得被人砍  阅读(847)  评论(0)    收藏  举报