码迷,mamicode.com
首页 > Web开发 > 详细

web页面实现emptyText 效果 兼容firefox/google/360

时间:2017-05-24 14:33:22      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:注意   var   cti   pen   closed   ace   ble   别名   pre   

第一步:

$("[name=‘sql‘]").attr({"placeholder" : "内
容"}); 

结果显示:内
容

第二步:

<textarea name="sql" id="sql" class="mini-textarea" rows="20" required="true" requiredErrorText="SQL不能为空"  emptyText="aaabb&#10;cccc"></textarea>

这样写,在谷歌、360都可以换行,火狐不行

第三步:

<textarea name="sql" id="sql" class="mini-textarea" rows="20" required="true" requiredErrorText="SQL不能为空"  ></textarea>

技术分享
 1     var placeholder="SQL查询注意事项:\r\n(1)目前已自动添加了条数限制,最大为1000条,不需要sql添加条数限制;\r\n(2)where 条件中包含时间的,需使用to_date(...)函数进行转换;\r\n(3)使用自定义函数需加别名;\r\n(4)查询结果提示\"table or view does not exist\"时,需确认数据表是否存在,或者数据源、数据库名是否正确;";
 2     $("[name=‘sql‘]").css({"color" : "gray"});
 3     $("[name=‘sql‘]").val(placeholder);
 4     $("[name=‘sql‘]").focus(function() {
 5         if ($(this).val().contains("SQL查询注意事项:")) {
 6             $(this).val(‘‘);
 7             $(this).css({"color" : "black"});
 8         }
 9     });
10 
11     $("[name=‘sql‘]").blur(function() {
12         if ($(this).val() == ‘‘) {
13             $(this).val(placeholder);
14             $(this).css({"color" : "gray"});
15         }
16     });
View Code

即可。

技术分享

web页面实现emptyText 效果 兼容firefox/google/360

标签:注意   var   cti   pen   closed   ace   ble   别名   pre   

原文地址:http://www.cnblogs.com/loveok-56/p/6898488.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!