<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>