通过js修改input、select默认字体颜色
textarea默认字颜色以及获取焦点后的字的颜色,焦点获取后使默认消失
输入您要输入的内容
select默认选中项颜色为灰色,选择后变为黑色(js实现)
input有默认值,且为灰色,点击后默认值消失,输入值变为黑色
$(function(){ //集体调用类型为text的input $(".forminput[text]").each(function(){ $(this).setDefauleValue(); }); //单个调用 $("#key").setDefauleValue(); }) //设置默认值 $.fn.setDefauleValue=function(){ vardefauleValue=$(this).val(); $(this).val(defauleValue).css("color","#eee"); returnthis.each(function(){ $(this).focus(function(){ if($(this).val()==defauleValue){ $(this).val("").css("color","#000");//输入值的颜色 } }).blur(function(){ if($(this).val()==""){ $(this).val(defauleValue).css("color","#999");//默认值的颜色 } }); }); }
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志