jQuery学习16---搜索文本框效果

来源:互联网 发布:黑龙江省网络教育 编辑:程序博客网 时间:2024/04/29 14:38



<html><head><meta http-equiv="Content-Type" content="text/html;charset=GBK"><title></title><script src="../jquery-1.8.2.js" type="text/javascript"></script><style type="text/css">.black{color:Black;}.gray{color:Gray;}</style><script type="text/javascript">$(function(){$("#textSearch").focus(function(){//先判断当前输入框中的文字if($(this).val() =="请输入搜索关键字"){$(this).val("").attr("class","black");}}).blur(function(){if($(this).val().length==0 || $(this).val() =="请输入搜索关键字"){$(this).val("请输入搜索关键字").attr("class","gray");}});});</script></head><body><input id="textSearch" type="type" value="请输入搜索关键字" class="gray" /><input id="btn" type="button" value="搜索"></body></html>


原创粉丝点击