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 ...
随机推荐
- [翻译]lithium 快速上手(QuickStart)
快速入门 经典博客教程 很感谢你尝试Li3!这一部分栏目为那些想了解这个框架可以做什么的php用户所设计.像这样深入代码是一种很好的方式去体会快速应用开发(Rapid Application ...
- HDU 1525 Euclid's Game 博弈
Euclid's Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- React 快速入门小记
大约半个月前,我一直在思考一个问题,Angular.React 和 Vue,究竟该学什么? 听取了几位前辈的意见,也综合考虑了各方面的原因,最终选择了 React,希望我"没有选错" ...
- 部署网站出现System.ServiceModel.Activation.HttpModule错误
1. 部署网站到IIS7.5,Window 2008的时候出现这个错误 2. 错误信息 Server Error in '/' Application. Could not load type 'Sy ...
- html 上传预览图片
直接上代码了 <!DOCTYPE html> <html><head lang="en"><meta http-equiv="C ...
- Node聊天程序实例01
作者:vousiu 出处:http://www.cnblogs.com/vousiu 本实例参考自Mike Cantelon等人的<Node.js in Action>一书. 本实例要实现 ...
- 离线更新VSAN HCL数据库
从VSAN 6.0起,VSAN提供了Health Check功能,其中就包括VSAN HCL数据库,通过此运行状况检查验证用于 HCL 检查的 VMware 兼容性指南数据库是否是最新的.这些 VCG ...
- 电子爱好者DIY篇
2016/7/15 电子爱好者DIY篇 一年和之前就想到了一些感悟,现在有些模糊的清晰起来了,但还是不够清晰,故写下来做个日志. 结论 首先把结论放在前面.目前随着电子集成电路的发展,电子DIY越来越 ...
- 如何在页面进入时就加载js
页面一打开就执行JS的代码! onLoadwindow.onLoad=function(){}window.onload=function(){ } 补充:window.onload和doucumen ...
- JavaScript 深入了解基本类型和引用类型的值
转载:https://segmentfault.com/a/1190000006752076 一个变量可以存放两种类型的值,基本类型的值(primitive values)和引用类型的值(refere ...