<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>input标签获取焦点时清空文本框内提示信息</title>
<script type="text/javascript">
function addLoadEvent(funct){
var oldonload = window.onload;
if (typeof window.onload != 'function'){
window.onload = funct;
}else{
window.onload = function(){
oldonload();
funct();
}
}
}
function checkInput(){
var inputId = document.getElementById('c_input');
var inputDefault = '请输入搜索字符';
function cls(){
if (this.value == inputDefault){
this.value = '';
}
}
function res(){
if (this.value == ''){
this.value = inputDefault;
}
}
inputId.onfocus = cls;
inputId.onblur = res;
}
addLoadEvent (checkInput);
</script>
</head>
<body>
<input type="text" value="请输入搜索字符" id="c_input" />
</body>
</html>