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 ...
随机推荐
- 【转载】Windows 7 不同安装模式简要区别(图解)
---------------------------------------------------------------------------------------------------- ...
- mysql 5.7.16安装与给远程连接权限
ZIP Archive版是免安装的.只要解压就行了.不需要安装.我的放在d盘啦. 1.配置: 也就是my.ini文件的由来. 把my-default.ini(此文件是解压之后,自带的)这个文件复制一下 ...
- IBM X3850 Windows 无法安装到这个磁盘。选中的磁盘具有MBR分区表。在 EFI 系统上,Windows 只能安装到 GPT 磁盘
以前安装的是window2003 32位, 改装为2012 64位的时候.出现 Windows 无法安装到这个磁盘.选中的磁盘具有MBR分区表.在 EFI 系统上,Windows 只能安装到 GPT ...
- 【翻译】利用Qt设计师窗体在运行时创建用户界面(Creating a user interface from a Qt Designer form at run-time)
利用Qt设计师窗体在运行时创建用户界面 我们利用Calculator窗体例子中创建的窗体(Form)来展示当一个应用(application)已经生成后,是可以在其运行时产生与例子中相同的用户界面. ...
- 最全面的常用正则表达式大全 zz
很多不太懂正则的朋友,在遇到需要用正则校验数据时,往往是在网上去找很久,结果找来的还是不很符合要求.所以我最近把开发中常用的一些正则表达式整理了一下,包括校验数字.字符.一些特殊的需求等等.给自己留个 ...
- PHPExcel对于Excel中日期和时间类型的处理
PHPExcel是一款优秀的处理Excel文件读写的开源PHP Library,能够给我们提供强大的Excel读写能力,本文针对Excel处理过程中关于日期和时间类型的处理进行深入的讨论.PHPExc ...
- 第三讲. COTS包交换介绍
COTS里面涉及到虚拟机的概念,所以网络稍微复杂一点点. 基本概念 目前虚拟机里面常见的网卡控制器有三类: 半虚拟化网卡设备,由Hypervisor统一管理,虚拟机里面采用特定的接口进行调用. 透传网 ...
- Xcode7 *** does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE)
*** does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE ...
- 插件开发--BE插件开发
U9的插件主要分为3种,即(1)BE插件(2)UI插件(3)BP/SV插件 1.新建类库解决方案 2.新建插件类,并引用以下dll,UBF安装目录U9.VOB.Product.UBF\UBFStudi ...
- java面向对象的语言
对象:真实存在唯一的事物. 类: 实际就是对某种类型事物的共性属性与行为的抽取. 抽象的概念.... 车 我们从小的时候就不断的接触很多的对象,我们的大脑就会把 这些具备相同属性与行为的事物进行分类. ...