南强小屋 Design By 杰米
效果图:

具体实现:
1、textarea标签内容
复制代码 代码如下:
<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、初始化使点击添加按钮时,内容显示最多能输入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失去焦点且内容为空时,显示提示信息
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.鼠标点击文本框,默认文字消失,点击文本框外任意区域,默认文字又重现:
<textarea onfocus=”if(value=='白鸽男孩') {value=' ‘}” onblur=”if(value==' ‘) {value='白鸽男孩'}”>白鸽男孩</textarea>
<textarea onfocus=”if(value=='白鸽男孩') {value=' ‘}” onblur=”if(value==' ‘) {value='白鸽男孩'}”>白鸽男孩</textarea>
5.鼠标移至文本框,默认文字消失,鼠标移出文本框,默认文字又重现:
<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.鼠标单击文本框,文本框内任何文字消失(包括默认文字及后来输入的文字):
<textarea onclick=”value=' ‘”>白鸽男孩</textarea>
<textarea onclick=”value=' ‘”>白鸽男孩</textarea>
7.鼠标移至文本框,文本框内任何文字消失(包括默认文字及后来输入的文字):
<textarea onmouseover=”value=' ‘”>白鸽男孩</textarea>
<textarea onmouseover=”value=' ‘”>白鸽男孩</textarea>
8.单击文本框后全选文本框内的文字:
<textarea onfocus=”select()”>白鸽男孩</textarea>
<textarea onfocus=”select()”>白鸽男孩</textarea>
9.鼠标移至文本框全选文本框内的文字:
<textarea onmouseover=”focus()” onfocus=”select()”>白鸽男孩</textarea>
<textarea onmouseover=”focus()” onfocus=”select()”>白鸽男孩</textarea>
10.回车后焦点从当前文本框转移到下一个文本框:
<textarea onkeydown=”if(event.keyCode==13)event.keyCode=9″>白鸽男孩</textarea>
<textarea onkeydown=”if(event.keyCode==13)event.keyCode=9″>白鸽男孩</textarea>
11.回车后焦点从当前文本框转移到指定位置:
<textarea onkeypress=”return focusNext(this,'指定位置的id名称',event)”>白鸽男孩</textarea> </span>

具体实现:
1、textarea标签内容
复制代码 代码如下:
<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、初始化使点击添加按钮时,内容显示最多能输入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失去焦点且内容为空时,显示提示信息
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.鼠标点击文本框,默认文字消失,点击文本框外任意区域,默认文字又重现:
<textarea onfocus=”if(value=='白鸽男孩') {value=' ‘}” onblur=”if(value==' ‘) {value='白鸽男孩'}”>白鸽男孩</textarea>
<textarea onfocus=”if(value=='白鸽男孩') {value=' ‘}” onblur=”if(value==' ‘) {value='白鸽男孩'}”>白鸽男孩</textarea>
5.鼠标移至文本框,默认文字消失,鼠标移出文本框,默认文字又重现:
<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.鼠标单击文本框,文本框内任何文字消失(包括默认文字及后来输入的文字):
<textarea onclick=”value=' ‘”>白鸽男孩</textarea>
<textarea onclick=”value=' ‘”>白鸽男孩</textarea>
7.鼠标移至文本框,文本框内任何文字消失(包括默认文字及后来输入的文字):
<textarea onmouseover=”value=' ‘”>白鸽男孩</textarea>
<textarea onmouseover=”value=' ‘”>白鸽男孩</textarea>
8.单击文本框后全选文本框内的文字:
<textarea onfocus=”select()”>白鸽男孩</textarea>
<textarea onfocus=”select()”>白鸽男孩</textarea>
9.鼠标移至文本框全选文本框内的文字:
<textarea onmouseover=”focus()” onfocus=”select()”>白鸽男孩</textarea>
<textarea onmouseover=”focus()” onfocus=”select()”>白鸽男孩</textarea>
10.回车后焦点从当前文本框转移到下一个文本框:
<textarea onkeydown=”if(event.keyCode==13)event.keyCode=9″>白鸽男孩</textarea>
<textarea onkeydown=”if(event.keyCode==13)event.keyCode=9″>白鸽男孩</textarea>
11.回车后焦点从当前文本框转移到指定位置:
<textarea onkeypress=”return focusNext(this,'指定位置的id名称',event)”>白鸽男孩</textarea> </span>
标签:
textarea,焦点
南强小屋 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
南强小屋 Design By 杰米
暂无textarea焦点的用法实现获取焦点清空失去焦点提示效果的评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。