点击搜索,获得焦点搜索框为空,失去焦点,显示默认
<div class="search-box" style="float:left;margin-top: 0px;margin-left: 75px;">
<form id="searchForm" name="searchForm" action="ithelpdesk/search/searchInfo.jsp" target="_blank" method="post">
<input type="text" id="searchText" placeholder="输入关键字" style="margin-top:0px;width: 230px;color:rgb(0,0,0);" onkeypress="if(event.keyCode == 13) search();"
onfocus="inputgetfocus();" onblur="inputonblur();"/>
<button type="button" style="margin-top:0px" onclick="search()">搜索</button>
</form>
</div>
<script>
function inputgetfocus(){
var defval = $("#searchText").attr("placeholder");
if("输入关键字"==defval)
{
$("#searchText").attr("placeholder","");
$("#searchText").css("color","#000");
}
}
function inputonblur(){
var thisval = $("#searchText").val();
if(thisval==""){
$("#searchText").attr("placeholder","输入关键字");
}
}
</script>