[英]Pre-fill input text box
有誰知道一小段很好的代碼,這些代碼可以預填充我的用戶,並在輸入框中傳遞文本用戶名和密碼。 我看過jscript可以做到這一點,但我正在尋找的是幾行代碼。
與右側上方搜索框中的搜索文本相似
對於支持HTML5的瀏覽器,添加placeholder =“ search”將自動添加預填充文本。
頁面頂部的搜索文本框包含:
<input type="text" placeholder="search" >
您可以使用HTML5填充程序來使其向后兼容。 示例: http : //kamikazemusic.com/web-development/revisiting-html5-placeholder-fixes/
您可以使用以下內容:
<input type="text" style="color:#ccc;" value="username" onfocus="this.value = this.value=='username' ? '' : this.value; this.style.color='#000';" onfocusout="this.value = this.value == '' ? this.value = 'username' : this.value; this.value=='username' ? this.style.color='#ccc' : this.style.color='#000'"/>
<input type="text" style="color:#ccc;" value="password" onfocus="this.value = this.value=='password' ? '' : this.value; this.style.color='#000';" onfocusout="this.value = this.value == '' ? this.value = 'password' : this.value; this.value=='password' ? this.style.color='#ccc' : this.style.color='#000'"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.