//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兼容的更多相关文章

  1. placeholder在不同浏览器下的表现及兼容方法 placeholder兼容

    1.什么是placeholder?    placeholder是html5新增的一个属性,当input或者textarea设置了该属性后,该值的内容将作为灰字提示显示在文本框中,当文本框获得焦点(或 ...

  2. placeholder兼容

    <!------------placeholder兼容-------------><script type="text/javascript">    $( ...

  3. placeholder兼容方法(兼容IE8以上浏览器)

    //placeholder兼容方法(兼容IE8以上浏览器) var JPlaceHolder = { //检测 _check: function () { return 'placeholder' i ...

  4. IE8 placeholder兼容+Password兼容

    对于placeholder兼容问题 IE系列的大部分不兼容 使用JQ插件解决这个问题,确实用法很简单 jS下载地址http://www.ijquery.cn/js/jquery.placeholder ...

  5. placeholder 兼容 IE

    placeholder 是 html5 的新属性,仅支持 html5 的浏览器才支持 placeholder,目前最新的 FF.Chrome.Safari.Opera 以及 IE10 都支持,IE6- ...

  6. ☆☆☆☆☆Placeholder兼容各大浏览器的例子☆☆☆☆☆

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  7. ie9 placeholder兼容

    .phcolor{ color:#999;}//css样式 function isPlaceholer(){ var input = document.createElement("inpu ...

  8. placeholder 兼容IE9以下版本 包含pasword

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. ie9 placeholder兼容代码方法

    function guid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r ...

随机推荐

  1. mybatis 如何使用乐观锁

    悲观锁的问题: 因为悲观锁大多数情况下依靠数据库的锁机制实现,以保证操作最大程度的独占性.如果加锁的时间过长,其他用户长时间无法访问,影响了程序的并发访问性,同时这样对数据库性能开销影响也很大,特别是 ...

  2. html5的新特性——拖放API

    在HTML5之前只能使用鼠标事件模拟出"拖放"效果:HTML5专门为拖放提供了7个事件句柄.  被拖动的源对象可以触发的事件: (1)ondragstart:源对象开始被拖动 (2 ...

  3. 第十一章 GUI 上

     第11章 GUI程序设计 11.1 JFC简介 JFC(Java Foundation Class) 作为CUI(Graphic User Interface)设计的基础.JFC包含AWT(Abst ...

  4. 通过js给android控件WebView设padding

    项目中有个界面是用来显示一个网页的,很简单,放个WebView就ok了,可是返回按钮放在哪 ,ui的设计是在底部显示一个半透明的条,左边有一个返回按钮.这个条显示在内容上面.我有一个担心,就是要是最下 ...

  5. 29.Hadoop之HDFS集群搭建笔记

    0.修改IP,主机名,hosts文件         setup        修改网卡IP         service  network  restart        重启网络服务使IP生效 ...

  6. Node.js学习笔记:setImmediate与process.nextTick

    通过process.nextTick注册的函数在当前这个事件循环中执行的函数执行完毕后立即执行,相当于把当前的同步代码执行完毕之后,立刻执行所有的通过process.nextTick注册的函数,如果注 ...

  7. ASP.NET MVC Jquery Validate 表单验证的多种方式

    在我们日常开发过程中,前端的表单验证很重要,如果这块处理不当,会出现很多bug .但是如果处理的好,不仅bug会很少,用户体验也会得到很大的提升.在开发过程中我们可以不借助 JS 库,自己去手写 JS ...

  8. java Collections.sort()实现List排序自定义方法

    方法一: package testSimple; import java.util.ArrayList; import java.util.Collections; import java.util. ...

  9. red hat安装mysql二进制包

    数据包命名格式解释 mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz 黑色粗体表示为包名称 蓝色表示linux系统二进制包 红色表示构架     1.上传mysql- ...

  10. fstream文件操作

    fstream(const char* filename, ios::openmode); ios::app: 以追加的方式打开文件 ios::ate: 文件打开后定位到文件尾,ios:app就包含有 ...