我在代碼中需要一些幫助。使用javascript的水印文本框
我想要的代碼動態就像在JavaScript中使用類,但我沒有太強大使用JavaScript。我需要你的解決方案。
例如,如果有人輸入文本框,文本框顯示文本「輸入關鍵詞或短語」。文字'輸入關鍵詞或短語'消失。如果不輸入或鼠標懸停在文本框上,則文本「輸入關鍵詞或短語」再次以灰色顯示。 我的代碼如下:
<asp:TextBox ID="txtQuery" runat="server" style="color: Gray;"
ValidationGroup="req" value='Enter key word or phrase'
onblur="if (this.value == '') { this.value = 'Enter key word or phrase';
this.style.color = 'Gray'; }"
maxlength="255" onfocus="if(this.value == this.defaultValue){this.value='';
this.style.color='Black'}"></asp:TextBox>
請幫忙。
您的目標是搜索什麼東西?數據庫或使用想要使用Google搜索。 – adatapost
我不認爲我理解你的問題,因爲你的代碼有效。看到這個jsfiddle:http://jsfiddle.net/NdkwJ/ – Icarus
你試圖使用代碼添加它後面 – Binil