您的位置:首页 > 编程语言 > Go语言

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

2017-05-24 13:28 393 查看
第一步:

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

结果显示:内 容

第二步:

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

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

第三步:

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

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\"时,需确认数据表是否存在,或者数据源、数据库名是否正确;";
$("[name='sql']").css({"color" : "gray"});
$("[name='sql']").val(placeholder);
$("[name='sql']").focus(function() {
if ($(this).val().contains("SQL查询注意事项:")) {
$(this).val('');
$(this).css({"color" : "black"});
}
});

$("[name='sql']").blur(function() {
if ($(this).val() == '') {
$(this).val(placeholder);
$(this).css({"color" : "gray"});
}
});


View Code
即可。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: