1 var CHelper={
 2     ClrKey:function(selector,key){
 3         $(selector).focus(function(){
 4             if($.trim($(this).val())==key){$(this).val("");}
 5             $(this).css("color","#000000");
 6         });
 7 
 8         $(selector).blur(function(){
 9             var v=$.trim($(this).val());
10             if(v.length<1 || v==key){
11                 $(this).val(key);
12                 $(this).css("color","");
13             }
14         });
15     },
16     ClrObj:function(selector){
17         CHelper.ClrKey(selector,$(selector).val());
18     }
19 }

 

CHelper.ClrKey("#txtContent","请输入内容");

CHelper.ClrObj("#txtContent");

posted on 2012-05-03 13:24  CodeBase  阅读(396)  评论(0编辑  收藏  举报