<
html
>
< head >
< title > 文本框中的提示 </ title >
< script type ="text/javascript" >
var tipText = "<请输入关键字>";
document.getElementById("keyword").value = tipText;
function clearTip(){
var keyword = document.getElementById("keyword");
if(keyword.value == tipText){
keyword.value = "";
}
}
function setTip(){
var keyword = document.getElementById("keyword");
if(keyword.value == ""){
keyword.value = tipText;
}
}
</ script >
</ head >
< body >
< input type ="text" id ="keyword" onfocus ="clearTip()" onblur ="setTip()" value ="" >
</ body >
</ html >
< head >
< title > 文本框中的提示 </ title >
< script type ="text/javascript" >
var tipText = "<请输入关键字>";
document.getElementById("keyword").value = tipText;
function clearTip(){
var keyword = document.getElementById("keyword");
if(keyword.value == tipText){
keyword.value = "";
}
}
function setTip(){
var keyword = document.getElementById("keyword");
if(keyword.value == ""){
keyword.value = tipText;
}
}
</ script >
</ head >
< body >
< input type ="text" id ="keyword" onfocus ="clearTip()" onblur ="setTip()" value ="" >
</ body >
</ html >