2011-06-08 67 views
0

鏈接示例如下:http://jsfiddle.net/fxr5p/如何使值爲空,onload工作onblur函數?顯示type your keyword,然後點擊輸入部分,onblur單詞disapear?謝謝。js輸入onBlur在頁面載入時不工作

<input type="text" value="" id="search" name="Search" onblur="if(this.value=='') this.value='type your keyword';" onfocus="if(this.value=='type your keyword') this.value='';"> 

回答

0
<script> 
    document.body.onload = function() 
    { 
    document.getElementById("search").value = "type your keyword"; 
    } 
</script> 
0

試試這個:

<input type="text" value="type your keyword" id="search" name="Search" onblur="if(this.value=='') this.value='type your keyword';" onfocus="if(this.value=='type your keyword') this.value='';"> 
0

我覺得你幾乎沒有,只是用value="type your keyword"