placeholder 兼容IE9以下版本 包含pasword
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>
PlaceHolder
</title>
<style type="text/css">
/* 设置提示文字颜色 */
::-webkit-input-placeholder {
color: #;
}
:-moz-placeholder {
color: #;
}
.placeholder {
color: #ccc;
}
</style>
</head>
<body>
<input type="text" onkeyup="this.value=this.value.replace(/^ +| +$/g,'')">
登录用户名、密码文字提示,鼠标离开显示文字 html5 and jquery<br/>
<br/>
账号:<input type="text" name="email" placeholder = '用户账号' /><br/>
<br/>
密码:<input type="password" name="password" placeholder = '密码' autocomplete="off" /><br/>
</body>
</html>
<script src="http://js.static.m1905.cn/core/jquery-edge.min.js"></script>
<script>
//判断浏览器是否支持 placeholder属性
function isPlaceholder(){
var input = document.createElement('input');
return 'placeholder' in input;
} if(!isPlaceholder()){ //不支持placeholder 用jquery来完成
$("input").not("input[type='password']").each(function(){//把input绑定事件 排除password框
if($(this).val()=="" && $(this).attr("placeholder")!=""){
$(this).val($(this).attr("placeholder"));
$(this).focus(function(){
if($(this).val()==$(this).attr("placeholder")) $(this).val("");
});
$(this).blur(function(){
if($(this).val()=="") $(this).val($(this).attr("placeholder"));
});
}
});
//对password框的特殊处理1.创建一个text框 2获取焦点和失去焦点的时候切换
var pwdField = $("input[type=password]");
var pwdVal = pwdField.attr('placeholder');
pwdField.after('<input id="pwdPlaceholder" type="text" value='+pwdVal+' autocomplete="off" />');
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();
}
});
} </script>
placeholder 兼容IE9以下版本 包含pasword的更多相关文章
- background兼容IE9以下版本
.box { width:100%; height:80%; background: url('img/nav_bg.png') no-repeat; backgrou ...
- pc端兼容IE9及以上版本
最近业务部门反映我们商城的兼容性不是很好,尤其是在IE浏览器上,经过调研,我们决定对IE9及以上版本的IE内核浏览器进行主流程测试,发现有哪些功能在IE9上不兼容 一.CSS兼容性 如下图所示 使用了 ...
- IE9以下 placeholder兼容
//input placeholder兼容!(function ($, doc, win) { $.fn.placeholder = function () { var i = doc.createE ...
- 兼容ie10以下版本的placeholder属性
<script src="${ctx }/js/jquery.placeholder.js" type="text/javascript">< ...
- AngularJS开发指南7:AngularJS本地化,国际化,以及兼容IE低版本浏览器
AngularJS本地化,国际化 国际化,简写为i18n,指的是使产品快速适应不同语言和文化. 本地化,简称l10n,是指使产品在特定文化和语言市场中可用. 对开发者来说,国际化一个应用意味着将所有的 ...
- placeholder在不同浏览器下的表现及兼容方法 placeholder兼容
1.什么是placeholder? placeholder是html5新增的一个属性,当input或者textarea设置了该属性后,该值的内容将作为灰字提示显示在文本框中,当文本框获得焦点(或 ...
- vue拦截器实现统一token,并兼容IE9验证
项目中使用vue搭建前端页面,并通过axios请求后台api接口,完成数据交互.如果验证口令token写在在每次的接口中,也是个不小的体力活,而且也不灵活.这里分享使用vue自带拦截器,给每次请求的头 ...
- input placeholder 兼容问题
placeholder是html5出的新特性,ie9以下是不兼容的, 那么为了兼容ie9 我们需要对他做处理 //jq的处理方式$(function(){ jQuery('[placeholder] ...
- 前端表单提交,提交有图片出现的问题,及解决方案 兼容ie9
更新一下我的小园子,主要说的是jq文件上传的过程中,如果出现上传的文件里有图片问题 其实文件上传有图片的情况下,不是什么大问题,对于前端来说,但是,如果需要兼容ie9的时候,就需要处理一下 文件上传如 ...
随机推荐
- 内核request_mem_region 和 ioremap的理解
request_mem_region仅仅是linux对IO内存的管理,意思指这块内存我已经占用了,别人就不要动了,也不能被swap出去.使用这些寄存器时,可以不调用request_mem_region ...
- QListWidget代码刷新界面
我有一个特殊效果要求实现(其实很弱智,也变成特殊效果,汗一下自己):两个QRadioButton切换的时候,让旁边的QListWidget自动变化不同的背景色.想了很多办法: 1. 控件自己刷新,不行 ...
- *MySQL卸载之后无法重装,卡在Apply security settings:Error Nr.1045
- 123. Best Time to Buy and Sell Stock III
题目: Say you have an array for which the ith element is the price of a given stock on day i. Design a ...
- Jquery attr()方法 属性赋值和属性获取
jquery中用attr()方法来获取和设置元素属性,attr是attribute(属性)的缩写,在jQuery DOM操作中会经常用到attr(),attr()有4个表达式. 1. attr(属性名 ...
- Spring事务Transaction配置的五种注入方式详解
Spring事务Transaction配置的五种注入方式详解 前段时间对Spring的事务配置做了比较深入的研究,在此之间对Spring的事务配置虽说也配置过,但是一直没有一个清楚的认识.通过这次的学 ...
- poj 2503 Babelfish (查找 map)
题目:http://poj.org/problem?id=2503 不知道为什么 poj 的 数据好像不是100000,跟周赛的不一样 2000MS的代码: #include <iostrea ...
- 2434: [Noi2011]阿狸的打字机
ac自动机,bit,dfs序. 本文所有的stl都是因为自己懒得实现. 首先x在y里面出现,就意味y节点可以顺着fail回去. 反向建出一个fail数,然后搞出dfs序列.找出x对应的区间有多少个 ...
- ExecutorService与Executors例子的简单剖析
对于多线程有了一点了解之后,那么来看看java.lang.concurrent包下面的一些东西.在此之前,我们运行一个线程都是显式调用了Thread的start()方法.我们用concurrent下面 ...
- amoeba安装与实现amoeba for mysql读写分离
运行环境 l CentOS6.3 l Jdk1.6.0_30 l amoeba-mysql-binary-2.2.0 l amoeba:192.168.88.17 l master1:192 ...