ie8的input的placeholder不显示的解决bug
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery1.10.2.min.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
.input-item {
position: relative;
margin: 10px;
}
.pwd-place {
position: absolute;
top: 0;
left: 72px;
width: 100%;
height: 100%;
font-size: 12px;
}
</style>
</head>
<body>
<form action="#">
<div class="input-item">
<label for="userName">用户名:</label>
<input class="username" id="userName" type="text" placeholder="请输入用户名">
</div>
<div class="input-item">
<label for="pwd">密码:</label>
<input class=" password" id="pwd" type="password" placeholder="请输入密码">
<span class="pwd-place"></span>
</div>
</form>
<script src="jquery-1.11.3.js"></script>
<script>
function placeholder(el){
function isPlaceholer(){
var input = document.createElement("input");
return "placeholder" in input;
}
var $el = $(el);
if( isPlaceholer()==false && !('placeholder' in document.createElement('input')) ){
$('input[placeholder],textarea[placeholder]').each(function(){
var that = $(this),
text= that.attr('placeholder');
if(that.val()===""){
if(that.attr("type") == "password"){
$el.html("请输入密码");
}else {
that.val(text).addClass('placeholder');
}
}
that.focus(function(){
if($el.html() == text){
$el.html("");
}
if(that.val()===text) {
that.val("").removeClass('placeholder');
}
})
.blur(function(){
if(that.val()==="") {
if (that.attr("type") == "password") {
$el.html("请输入密码");
}else {
that.val(text).addClass('placeholder');
}
}
})
.closest('form').submit(function(){
if(that.val() === text){
that.val('');
}
});
});
}
}
$(document).ready(function() {
placeholder(".pwd-place")
});
</script>
</body>
</html>
ie8的input的placeholder不显示的解决bug的更多相关文章
- iphone H5 input type="search" 不显示搜索 解决办法
H5 input type="search" 不显示搜索 解决办法 H5 input type="search" 不显示搜索 解决方法 在IOS(ipad iP ...
- H5 input type="search" 不显示搜索 解决方法
在IOS(ipad iPhone等)系统的浏览器里打开H5页面.如下写法: <input type="search" name="search” id=" ...
- input 的 placeholder属性在IE8下的兼容处理
placeholder是input标签的新属性,在使用的时候有两个问题: 1.IE8 下不兼容 处理思路: 如果浏览器不识别placeholder属性,给input添加类名placeholder,模仿 ...
- 类似于input输入框placeholder的效果,兼容ie8
$(function(){ //判断浏览器是否支持placeholder属性 supportPlaceholder='placeholder'in document.createElement ...
- js解决IE8、9下placeholder的兼容问题
由于placeholder是html5的新属性,在IE8.IE9下是不能显示的,有兼容性问题. 解决思路: 1.判断目前浏览器是否支持placeholder属性 2.若不支持,则将type=" ...
- 兼容IE8的input输入框的正确使用姿势
input是一个很常见的标签,大家使用的也很常见,但是我在具体的工作中发现要想完美的使用这个标签还是任重而道远,下面是我碰到的几个问题. 1.我们在使用这个标签的时候会习惯的加上placeholder ...
- H5新特性 input type=date 在手机上默认提示显示无效解决办法
目前PC端对input 的date类型支持不好,我试下来的结果是只有chrome支持.firefox.IE11 都不支持.而且PC端有很多日历控件可供使用.就不去多考虑这点了. 那么在移动端的话,io ...
- 在IE8等不支持placeholder属性的浏览器中模拟placeholder效果
placeholder是一个很有用的属性,可以提示用户在input框中输入正确的内容,但是IE8以及IE8一下的浏览器不支持该属性,我们可以使用js来模拟相似的效果.下面直接上代码: <!doc ...
- IE8 不支持html5 placeholder的解决方案
IE8不支持html5 placeholder的解决方法. /** * jQuery EnPlaceholder plug * version 1.0 2014.07.01戈志刚 * by Frans ...
随机推荐
- Python-接口自动化(九)
python操作Excel处理测试数据(九) (十)python操作Excel读/写测试数据 1.夹心饼干 setUp:在每一条测试用例执行之前执行 tearDown:在每一条测试用例执行之后执行 上 ...
- CEPH集群操作入门--配置
参考文档:CEPH官网集群操作文档 概述 Ceph存储集群是所有Ceph部署的基础. 基于RADOS,Ceph存储集群由两种类型的守护进程组成:Ceph OSD守护进程(OSD)将数据作为对象 ...
- Buzzsumo大型教程(内容营销+外链outreach必备)营销神器
做内容营销,Buzzsumo基本是必备工具.做谷歌白帽SEO的百分八十应该都用过或者至少接触过.在国外就更不用说了,很多网络营销大牛眼里,Buzzsumo的重要程度绝对超过Ahrefs! Buzzsu ...
- python入门(四)
今天主要记录下python中文件的编辑与函数. 一.修改文件 一)简单粗暴--直接修改 1.打开一个文件,获取到所有内容2.对内容进行修改3.清空原来的文件4.把新的内容写进去 f = open('u ...
- oracle问题 ORA-01843:not a valid month
解决思路: 开始解决问题走了些弯路,搜了一些资料,结果大部分说的是修改会话的nls_date_language参数 可是线上正式项目,不能说改就改吧 就找其他方式解决 最终找到问题,to_date() ...
- 如何用jmeter进行数据库性能测试
由于业务需要,需要进行数据库性能测试,记录过程进行学习 测试前期准备: 1.测试点准备及需求点 a.性能测试目的 b.jmeter测试数据库基本脚本 get c.数据库性能监控工具选择 d.服务器性 ...
- hibernate学习以及文件以及注释
<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE hibernate-configuration PUBLIC "-//Hib ...
- 安装mavlink遇到的问题(future找不到)
从官网下载mavlink(git clone https://github.com/mavlink/mavlink.git) 然后进入mavlink 目录执行 git submodule update ...
- linux安装虚拟机ping不通网关,ping不通外网问题解决(nat模式)
1.将网关字段改成自己想要的字段
- windows与sql身份登录
windows身份验证:1.“.”代表本地2.127.0.0.1代表本地3.本地ip地址,在dos中可查4.localhost代表本地 sql身份验证:首先用windows登上去,之后再安全性中找到登 ...