IE9以下 placeholder兼容
//input placeholder兼容
!(function ($, doc, win) {
$.fn.placeholder = function () {
var i = doc.createElement('input'),
placeholdersupport = 'placeholder' in i;
if (!placeholdersupport) {
var inputs = $(this);
inputs.each(function () {
var input = $(this),
text = input.attr('placeholder'),
pdl = 0,
height = input.outerHeight(),
width = input.outerWidth(),
placeholder = $('<span class="phTips_tadllj">' + text + '</span>');
try {
pdl = input.css('padding-left').match(/\d*/i)[0] * 1;
} catch (e) {
pdl = 5;
}
placeholder.css({ 'margin-left': -(width - pdl), 'height': height, 'line-height': height + "px", 'position': 'absolute', 'color': "#999", 'font-size': "14px", "z-index": "100" });
placeholder.click(function () {
//placeholder.css({display:'none'});
input.focus();
});
if ($.trim(input.val()).length > 0) {
placeholder.css({ display: 'none' });
} else {
placeholder.css({ display: 'inline' });
}
placeholder.insertAfter(input);
input.on("focus", function (e) {
placeholder.css({ display: 'none' });
}).on("blur", function (e) {
var _this = $(this);
if ($.trim(_this.val()).length > 0) {
placeholder.css({ display: 'none' });
}
else {
placeholder.css({ display: 'inline' });
}
});
// .keyup(function(e){
// if($(this).val() != ""){
// placeholder.css({display:'none'});
// }else{
// placeholder.css({display:'inline'});
// }
// })
});
}
return this;
};
var isIe = false;
if (navigator.userAgent.indexOf("MSIE") > 0) {
if (!$.support.leadingWhitespace || navigator.userAgent.indexOf("MSIE 9.0") > 0) {//IE9以下不让登陆
isIe = true;
}
}
if (isIe) {
$('input[placeholder]').placeholder();
}
})(jQuery, document, window);
IE9以下 placeholder兼容的更多相关文章
- placeholder在不同浏览器下的表现及兼容方法 placeholder兼容
1.什么是placeholder? placeholder是html5新增的一个属性,当input或者textarea设置了该属性后,该值的内容将作为灰字提示显示在文本框中,当文本框获得焦点(或 ...
- placeholder兼容
<!------------placeholder兼容-------------><script type="text/javascript"> $( ...
- placeholder兼容方法(兼容IE8以上浏览器)
//placeholder兼容方法(兼容IE8以上浏览器) var JPlaceHolder = { //检测 _check: function () { return 'placeholder' i ...
- IE8 placeholder兼容+Password兼容
对于placeholder兼容问题 IE系列的大部分不兼容 使用JQ插件解决这个问题,确实用法很简单 jS下载地址http://www.ijquery.cn/js/jquery.placeholder ...
- placeholder 兼容 IE
placeholder 是 html5 的新属性,仅支持 html5 的浏览器才支持 placeholder,目前最新的 FF.Chrome.Safari.Opera 以及 IE10 都支持,IE6- ...
- ☆☆☆☆☆Placeholder兼容各大浏览器的例子☆☆☆☆☆
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- ie9 placeholder兼容
.phcolor{ color:#999;}//css样式 function isPlaceholer(){ var input = document.createElement("inpu ...
- placeholder 兼容IE9以下版本 包含pasword
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- ie9 placeholder兼容代码方法
function guid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r ...
随机推荐
- 查看linux系统版本命令 (转)
查看linux系统版本命令 分类: Linux 知识小结2011-10-10 15:26 240162人阅读 评论(9) 收藏 举报 linuxredhatdebianx86susesun 一.查看内 ...
- 没人能阻止你,除了你自己——Keep up the good work!
今天在网上搜索一些关于计算机专业的论坛或者博客,于是发现了博客园,就进来了.我想把我的一些关于计算机科学与技术领域的学习经历纪录在此,以便于能和大家一起分享,一起努力,一起进步.说实话我是临床医学专业 ...
- 3.UIViewController详解
一. UIViewController,视图控制器,它是UIKit中非常重要的组成部分.它由控制器+View两部分组成. 控制器功能: ->实现代码逻辑,决定它自带的View的界面显示. -& ...
- 组合suan
/// 求从数组a[1..n]中任选m个元素的所有组合. /// a[1..n]表示候选集,n为候选集大小,n>=m>0. /// b[1..M]用来存储当前组合中的元素(这里存储的是元素 ...
- 【转载】推荐5款超实用的.NET性能分析工具
来源:http://www.csdn.net/article/2012-11-23/2812174-5-Good-and-useful-.NET-Profilers 虽然.NET框架号称永远不会发生内 ...
- html+js 的一些小问题
html+js 的一些小问题: 选择器+遍历函数: $("#taskStatusList tr:gt(0)").find("td:eq(3)").find(&q ...
- Openfire on Centos7
学习一下linux,装备 1)centos 最小安装.(找抽的节奏) 2)必备 oepnssh yum install openssh-server.x86_64 3)配置网络.打开 /etc/sys ...
- iOS app 企业内部发布及HTTPS服务器配置
转自: http://www.cnblogs.com/cocoajin/p/4082488.html iOS企业内部发布及HTTPS服务器配置 一:所需的条件 1. 苹果开发者证书,企业版 299$ ...
- 采用dom4j和反射模拟Spring框架的依赖注入功能
Spring的依赖注入是指将对象的创建权交给Spring框架,将对象所依赖的属性注入进来的行为.在学习了dom4j后,其实也可以利用dom4j和反射做一个小Demo模拟Spring框架的这种功能.下面 ...
- web前端图片极限优化策略
随着web的发展,网站资源的流量也变得越来越大.据统计,60%的网站流量均来自网站图片,可见对图片合理优化可以大幅影响网站流量,减小带宽消耗和服务器压力. 一.现有web图片格式 我们先来看下现在常用 ...