搜索框效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<style type="text/css">
.bc{ color:gray }
</style>
<script type="text/javascript">
$(function () {
$("input").val("请输入关键词").addClass("bc")
.blur(function () {//失去焦点时
if ($("input").val() == "")
$("input").val("请输入关键词").addClass("bc")
})
.focus(function () {//得到焦点时
if ($("input").val() == "请输入关键词")
$("input").val("").removeClass("bc")
});
});
</script>
</head>
<body>
<input type="text" />
</body>
</html>