goTOP
May 28, 2019

點擊 input 文字框內之預設文字時就移除預設文字的方法

| |
網頁語言 » JavaScript | 閱覽(9986) | Posted by apao at 14:04
▼加在一般 html 方法,以下的「輸入內容」要同時輸入兩邊。
說明:使用onfocus 事件,檢查value的內容,如果是初始內容,就將內容清空
<input type="text" value="輸入內容" onfocus="javascript:if(this.value=='輸入內容')this.value='';">

▼DEMO try it:

  
  


▼加在HTML5 的方法
說明:輸入文字時,預設文字才會消失。
<input id="email" type="text" placeholder="輸入內容" size="22" />

▼DEMO try it:

  
  
Facebook twitter LINEk
文章来自: 本站原創
0 Comment(s)
我要發表評論
暱稱
密碼 [ 訪客無需密碼 ]
電郵
網址
開啟HTML 開啟UBB 開啟表情 隱藏 記住我