搜索文本框焦点离开时文本位置跳动问题解决方法
发布时间:2016-12-27 来源:查字典编辑
摘要:搜索文本框焦点离开时设置文本,位置跳动问题//搜索文本框$("#txtSearch").focus(function(){if($(this...
搜索文本框焦点离开时设置文本,位置跳动问题
//搜索文本框
$("#txtSearch").focus(function () {
if ($(this).val() == "请输入搜索关键字") {
$(this).val("");
$(this).css("color", "black");
}
}).blur(function () {
if ($(this).val() == "") {
$(this).css("color", "gray").val("请输入搜索关键字");
}
});
在css中加入
#txtSearch
{
width:480px;
height:20px;
vertical-align:middle;
}