您的位置:首页 > Web前端 > JQuery

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

2013-06-29 14:13 411 查看


<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: