以前沒有這功能時,用JavaScript實現
<input type="text" name="search" id="search" value="" onfocus="onfocusState()" onblur="onfocusState()"/>
function onfocusState() {
if (document.getElementById("search").value == "請輸入關鍵字....") {
document.getElementById("search").value = "";
} else if (document.getElementById("search").value == "") {
document.getElementById("search").value = "請輸入關鍵字....";
} else { }
}
沒有留言:
張貼留言