複製画像:
特定の実装:
1。TextAreaタグコンテンツ
コードコピーは次のとおりです。
<span style = "font-size:14px;"> <tr>
<td align = "right" valign = "top">注:</td>
<td> <textarea name = "" id = "bere" cols = "" rows = "" onfocus = "this.classname = 'textarea220l'; this.onmouseout = ''; getaddfocus( 'areme');" onblur = "this.classname = 'textarea220'; this.onmouseout = function(){this.classname = 'textarea220'}; lostaddfocus( 'arem');" onmousemove = "this.classname = 'textarea220lg'" onmouseout = "this.classname = 'textarea220'"> </textarea> </td>
</tr> </span>
2。初期化により、[追加]ボタンをクリックすると、最大50ワードを入力できます。
コードコピーは次のとおりです。
<span style = "font-size:14px;"> $( "#introdution")。val( "最大50ワードを入力できます");
document.getElementById( "はじめに")。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がフォーカスを失い、コンテンツが空の場合、プロンプトメッセージが表示されます
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 == 'white dove boy'){value = ''} "> white dove boy </textarea>
<textarea onfocus =” if(value == 'white dove boy'){value = ''} "> white dove boy </textarea>
3.マウスをテキストボックスに移動すると、デフォルトのテキストが消えます。
<textarea onmouseover =” focus()” onfocus =” if(value == 'white dove boy'){value = ''} "> white dove boy </textarea>
<textarea onmouseover =” focus()” onfocus =” if(value == 'white dove boy'){value = ''} "> white dove boy </textarea>
4.マウスでテキストボックスをクリックし、デフォルトのテキストが消え、テキストボックスの外側の領域をクリックすると、デフォルトのテキストが再び再表示されます。
<textarea onfocus =” if(value == 'white dove boy'){value = ''} "onblur =" if(value == ''){value = 'white dove boy'} "> white boy </textarea>
<textarea onfocus =” if(value == 'white dove boy'){value = ''} "onblur =" if(value == ''){value = 'white dove boy'} "> white boy </textarea>
5.マウスをテキストボックスに移動し、デフォルトのテキストが消え、マウスがテキストボックスから出て移動し、デフォルトのテキストが再び表示されます。
<TextArea onMouseOver =” Focus()” onfocus =” if(value == 'white dove boy'){value = ''} "onmouseout =" blur() "onblur =" if(value == '' '){value =' white boy '} ">白いdove </textarea>
<TextArea onMouseOver =” Focus()” onfocus =” if(value == 'white dove boy'){value = ''} "onmouseout =" blur() "onblur =" if(value == '' '){value =' white boy '} ">白いdove </textarea>
6.マウスでテキストボックスをクリックすると、テキストボックスのテキストが消えます(デフォルトのテキストと後で入力したテキストを含む):
<textarea onclick =” value = ’' ">白い鳩の少年</textarea>
<textarea onclick =” value = ’' ">白い鳩の少年</textarea>
7.マウスをテキストボックスに移動すると、テキストボックスのテキストが消えます(デフォルトのテキストと後で入力したテキストを含む):
<textarea onmouseover =” value = ’' ">白い鳩の少年</textarea>
<textarea onmouseover =” value = ’' ">白い鳩の少年</textarea>
8。テキストボックスをクリックして、テキストボックス内のすべてのテキストを選択します。
<textarea onfocus = "select()"> white dove boy </textarea>
<textarea onfocus = "select()"> white dove boy </textarea>
9.マウスをテキストボックスに移動し、テキストボックスのすべてのテキストを選択します。
<textarea onmouseover =” focus()” onfocus =” select()”> white dove boy </textarea>
<textarea onmouseover =” focus()” onfocus =” select()”> white dove boy </textarea>
10。入力後、焦点は現在のテキストボックスから次のテキストボックスに転送されます。
<textarea onkeydown =” if(event.keycode == 13)event.keycode = 9″> white dove boy </textarea>
<textarea onkeydown =” if(event.keycode == 13)event.keycode = 9″> white dove boy </textarea>
11。入力後、焦点は現在のテキストボックスから指定された位置に転送されます。
<textarea onkeypress = "FocusNextを返す(this、 '指定された場所ID名'、event)"> white dove boy </textarea> </span>