亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

textarea焦點的用法實現(xiàn)獲取焦點清空失去焦點提示效果

 更新時間:2014年05月19日 17:10:57   作者:  
這篇文章主要介紹了textarea焦點的用法實現(xiàn)獲取焦點清空失去焦點提示效果,需要的朋友可以參考下
效果圖:

具體實現(xiàn):

1、textarea標簽內(nèi)容
復制代碼 代碼如下:

<span style="font-size:14px;"><tr>
<td align="right" valign="top">備注:</td>
<td><textarea name="" id="remark" cols="" rows="" class="textarea220" onfocus="this.className='textarea220L';this.onmouseout='';getAddFocus('remark');" onblur="this.className='textarea220';this.onmouseout=function(){this.className='textarea220'};lostAddFocus('remark');" onmousemove="this.className='textarea220Lg'" onmouseout="this.className='textarea220'"></textarea></td>
</tr></span>

2、初始化使點擊添加按鈕時,內(nèi)容顯示最多能輸入50個字
復制代碼 代碼如下:

<span style="font-size:14px;">$("#introduction").val("最多能輸入50個字");
document.getElementById("introduction").style.color="gray";</span>

3、js腳本
復制代碼 代碼如下:

<span style="font-size:14px;">function getAddFocus(id){//針對添加操作中的簡介和備注,textarea獲得焦點清空輸入框
var textarea=document.getElementById(id);
textarea.value="";
textarea.style.color="black";
}

function lostAddFocus(id){//針對添加操作中的簡介和備注,textarea失去焦點且內(nèi)容為空時,顯示提示信息
var textarea=document.getElementById(id);
var textarea_value=textarea.value;
if(textarea_value==""){
textarea.value="最多能輸入50個字";
textarea.style.color="gray";
}
}</span>

csdn小伙伴寫的textarea焦點的用法參考:
復制代碼 代碼如下:

<span style="font-size:14px;"> 1.文本框顯示默認文字:

<textarea>白鴿男孩</textarea>
<textarea>白鴿男孩</textarea>
  2.鼠標點擊文本框,默認文字消失:

<textarea onfocus=”if(value=='白鴿男孩') {value=' ‘}”>白鴿男孩</textarea>
<textarea onfocus=”if(value=='白鴿男孩') {value=' ‘}”>白鴿男孩</textarea>
  3.鼠標移至文本框,默認文字消失:

<textarea onmouseover=”focus()” onfocus=”if(value=='白鴿男孩') {value=' ‘}”>白鴿男孩</textarea>
<textarea onmouseover=”focus()” onfocus=”if(value=='白鴿男孩') {value=' ‘}”>白鴿男孩</textarea>
  4.鼠標點擊文本框,默認文字消失,點擊文本框外任意區(qū)域,默認文字又重現(xiàn):

<textarea onfocus=”if(value=='白鴿男孩') {value=' ‘}” onblur=”if(value==' ‘) {value='白鴿男孩'}”>白鴿男孩</textarea>
<textarea onfocus=”if(value=='白鴿男孩') {value=' ‘}” onblur=”if(value==' ‘) {value='白鴿男孩'}”>白鴿男孩</textarea>
  5.鼠標移至文本框,默認文字消失,鼠標移出文本框,默認文字又重現(xiàn):

<textarea onmouseover=”focus()” onfocus=”if(value=='白鴿男孩') {value=' ‘}” onmouseout=”blur()” onblur=”if (value==' ‘) {value='白鴿男孩'}”>白鴿男孩</textarea>
<textarea onmouseover=”focus()” onfocus=”if(value=='白鴿男孩') {value=' ‘}” onmouseout=”blur()” onblur=”if (value==' ‘) {value='白鴿男孩'}”>白鴿男孩</textarea>
  6.鼠標單擊文本框,文本框內(nèi)任何文字消失(包括默認文字及后來輸入的文字):

<textarea onclick=”value=' ‘”>白鴿男孩</textarea>
<textarea onclick=”value=' ‘”>白鴿男孩</textarea>
  7.鼠標移至文本框,文本框內(nèi)任何文字消失(包括默認文字及后來輸入的文字):

<textarea onmouseover=”value=' ‘”>白鴿男孩</textarea>
<textarea onmouseover=”value=' ‘”>白鴿男孩</textarea>
  8.單擊文本框后全選文本框內(nèi)的文字:

<textarea onfocus=”select()”>白鴿男孩</textarea>
<textarea onfocus=”select()”>白鴿男孩</textarea>
  9.鼠標移至文本框全選文本框內(nèi)的文字:

<textarea onmouseover=”focus()” onfocus=”select()”>白鴿男孩</textarea>
<textarea onmouseover=”focus()” onfocus=”select()”>白鴿男孩</textarea>
  10.回車后焦點從當前文本框轉(zhuǎn)移到下一個文本框:

<textarea onkeydown=”if(event.keyCode==13)event.keyCode=9″>白鴿男孩</textarea>
<textarea onkeydown=”if(event.keyCode==13)event.keyCode=9″>白鴿男孩</textarea>
  11.回車后焦點從當前文本框轉(zhuǎn)移到指定位置:

<textarea onkeypress=”return focusNext(this,'指定位置的id名稱',event)”>白鴿男孩</textarea> </span>

相關(guān)文章

最新評論