查询框实现无点击事件时默认颜色,点击时清空查询空,失去焦点且查询匡为空时还原默认状态

<input id="search" type="text" value="输入类别、编号、名称、主办、分类搜索">
$("#search").focus(function(){
              $(this).css("color","black");//点击后黑色
            $(this).addClass("focus");
            if($(this).val() ==this.defaultValue){  
                $(this).val("");           
            } 
            }).blur(function(){
            $(this).removeClass("focus");
            if ($(this).val() == '') {
              $(this).val(this.defaultValue);
              $(this).css("color","#C1C1C1");//失去焦点变原色
            }
          });

 

posted on 2016-12-19 19:54  ckx0709  阅读(235)  评论(0编辑  收藏  举报

导航