解决IE8placeholder属性问题
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>中宏网络商学院-用户登录</title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.min.js"></script>
</head>
<script type="text/javascript">
//判断浏览器是否支持 placeholder属性
function isPlaceholder() {
var input = document.createElement('input');
return 'placeholder' in input;
} $(document).ready(function () {
if (!isPlaceholder()) { //不支持placeholder 用jquery来完成
var loginAccount = document.getElementById('LoginAccount').getAttributeNode('placeholder').nodeValue;
var LoginPassword = document.getElementById('LoginPassword').getAttributeNode('placeholder').nodeValue;
var style = document.getElementById('LoginPassword').getAttributeNode('class').nodeValue;
$("input[id='LoginAccount']").each(//把input绑定事件 排除password框
function () { if ($(this).val() == "" && loginAccount != "") {
$(this).val(loginAccount);
$(this).focus(function () {
if ($(this).val() == loginAccount) $(this).val("");
});
$(this).blur(function () {
if ($(this).val() == "") $(this).val(loginAccount);
});
}
});
//对password框的特殊处理1.创建一个text框 2获取焦点和失去焦点的时候切换
var pwdField = $("input[type=password]");
var pwdVal = LoginPassword;
pwdField.after('<input id="pwdPlaceholder" type="text" value=' + pwdVal + ' autocomplete="off" class="' + style + '" tabindex = "2" />');
var pwdPlaceholder = $('#pwdPlaceholder');
pwdPlaceholder.show();
pwdField.hide(); pwdPlaceholder.focus(function () {
pwdPlaceholder.hide();
pwdField.show();
pwdField.focus();
}); pwdField.blur(function () {
if (pwdField.val() == '') {
pwdPlaceholder.show();
pwdField.hide();
}
}); if (document.getElementById('LoginValCode') != null) {
var LoginValCode = document.getElementById('LoginValCode').getAttributeNode('placeholder').nodeValue;
var style = document.getElementById('LoginValCode').getAttributeNode('class').nodeValue;
$("input[id='LoginValCode']").each(//把input绑定事件 排除password框
function () { if ($(this).val() == "" && LoginValCode != "") {
$(this).val(LoginValCode);
$(this).focus(function () {
if ($(this).val() == LoginValCode) $(this).val("");
});
$(this).blur(function () {
if ($(this).val() == "") $(this).val(LoginValCode);
});
}
});
}
}
}); </script>
<body>
<div class="wrap-full">
<div class="block-box block-box-1 mt-45">
<div class="block-body">
<div class="block-cont">
<div class="block-tit rel"><span class="ico abs"></span>用户登录</div>
<div class="clear">
<div class="w-4 mtb100 br fl">
<ul class="list-login">
<li><span class="ico ico-1"></span> <input type="text" class="ipt" id="LoginAccount" placeholder="请输入身份证号码"></li>
<li><span class="ico ico-2"></span> <input type="password" class="ipt" id="LoginPassword" placeholder="请输入密码"></li>
<li class="clear"><span class="ico ico-3"></span> <input type="text" class="ipt ipt-s fl" id="LoginValCode" placeholder="请输入验证码"><span class="code fr"><img src="data:images/code.jpg" alt=" "></span></li>
<li><button type="button" class="btn">立即登录</button></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
解决IE8placeholder属性问题的更多相关文章
- VS 错误解决(项目-属性-启用调试器)
我是先安装了VS2012, 之后由于需要安装了VS2008, 但在VS2012中可以运行程序但是不能调试, 即按Ctrl+F5可以运行, 但是按F5会提示错误. "尝试运行项目时出错:Unc ...
- BootstrapValidator 解决多属性被同时校验问题
问题描述:在使用bootstrapValidator插件校验表单属性,当表单属性过多需要每行并列多个属性 ,会出现校验第一个属性,发现整行被校验的效果 ,这不是我们工作想要的效果.如图: 问题分析:因 ...
- Java使用序列化的私有方法巧妙解决部分属性持久化问题
部分属性持久化问题看似很简单,只要把不需要的持久化的属性加上瞬态关键字(transient关键字)即可,没错,这也是一种解决方案,但在有的时候行不通,例如在一个计税系统和人力系统对接的时候,计税系统需 ...
- 解决opacity属性在低版本IE浏览器下失效的方法
以前,一直都以为ie9以下的版本不支持opacity属性.所以就同时使用 opacity和ie独特的filter蒙版.但是有些时候需要一些动态的效果,就比如层的渐渐消失,隐藏,就需要使用动态变化的op ...
- 周记3——解决fixed属性在ios软键盘弹出后失效的bug
这周在做空间(“类似”qq空间)项目.首页是好友发表的说说,可以针对每条说说进行评论,评论框吸附固定在屏幕底部.此时,Bug来了...在ios上,软键盘弹出后fixed属性失效了.后来发现,ios绝大 ...
- BootstrapValidator 解决多属性被同时校验问题《转》
问题描述:在使用bootstrapValidator插件校验表单属性,当表单属性过多需要每行并列多个属性 ,会出现校验第一个属性,发现整行被校验的效果 ,这不是我们工作想要的效果.如图: 问题分析:因 ...
- 如何解决Css属性text-overflow:ellipsis 不起作用(文本溢出显示省略号)
如何使text-overflow:elipsis起作用? 想要使用css属性text-overflow:elipsis起到作用,样式必须跟overflow:hidden; white-space:no ...
- 解决inline-block属性带来的标签间间隙问题
1.给inline-block元素设置一个父元素. 设置父元素的font-size:0:.子元素font-size设置成合适大小,如果不设置子元素font-size,子元素会继承父元素的0: 2.给i ...
- iOS开发解决 jsonModel 属性跟系统的重复
-(id)initWithDic:(NSDictionary *)dic { if (self = [super init]) { [self setValuesForKeysWithDictiona ...
随机推荐
- 參数传递(引用,指针,值传递)C++11
C++中,函数的參数传递方式有值传递.地址传递.传地址有指针和引用方式. 在函数參数中,传地址的理由有: 1.使被调函数能够改动主调函数中的数据对象: 2.传地址能够降低数据拷贝,提高程序运行速度. ...
- 创建一个显示所有预定义系统颜色的ListBox
原文 Creating a ListBox that Shows All Predefined System Colors 该System.Windows.SystemColors类包含了一系列揭露当 ...
- Some Very Good VC++/MFC Resources Besides Codeproject.com
Some Very Good VC++/MFC Resources Besides Codeproject.com http://www.naughter.com/ (VC++/MFC huge co ...
- WPF后台动画DoubleAnimation讲解
WPF后台动画,使用DoubleAnimation做的. 1.移动动画 需要参数(目标点离最上边的位置,目标点离最左边的位置,元素名称) Image mImage = new Image(); Flo ...
- Webx框架:Pipeline基本介绍
Pipeline. 它是管道的含义.一个管道阀门可以安装非常多.有许多可能的分支.它是用来控制页处理.它需要在被定义pipeline.xml文件.该文件是为每个阀的标签.该文件可以放一些简单的控制语句 ...
- android 如何使用jar替换java代码编译
1. 第一次全编译project(随机eng/user),然后保存,以取代java代码jar包,在alps/out/target/common/obj/JAVA_LIBRARIES/xxx__inte ...
- html5 命运之轮生产
码,如以下: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEn ...
- 【转载】MySQL Replication 环境安装与配置
安装[root@msr01 ~]# yum install mysql-serverInstalled:mysql-server.x86_64 0:5.1.73-3.el6_5 Dependency ...
- SQL Server 2016新特性:DROP IF EXISTS
原文:SQL Server 2016新特性:DROP IF EXISTS 在我们写T-SQL要删除某个对象(表.存储过程等)时,一般会习惯先用IF语句判断该对象是否存在,然后DROP,比如: 旧 ...
- SQLServer 远程服务器不存在,未被指定为有效的发布服务器,或您无权查看可用的发布服务器
原文:SQLServer 远程服务器不存在,未被指定为有效的发布服务器,或您无权查看可用的发布服务器 创建了事务发布,在初始化时出现错误,查看相关代理信息如下: 日志读取器代理错误: 状态: 0,代码 ...