//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. 【干货】微信场景之H5页面制作免费工具大集合

    营销代有手段出,各领风骚数百天.要说现在哪些营销方式最能传播,屡屡刷爆朋友圈的H5页面肯定就是首当其冲的,提到H5页面,就立马想到"围住神经猫",上线微信朋友圈3天的时间便创造了用 ...

  2. T-SQL编程练习(带注释)

    use test; GO /*创建自定义函数的格式: * create function 函数名(参数 数据类型) * returns 返回数据类型 as * begin * 代码 * end */ ...

  3. 携程Ctrip DAL的学习 2

    携程Ctrip DAL的学习 2 本人net开发菜鸟,原理请自行看github的官网源码. 我这里是简单的使用(helloworld的水平). 代码生成器的使用 详见 官网使用说明 注意的地方: 1 ...

  4. 百度-official

    1.请描述html5新增的一些标签,描述这些标签的用法和语义 2.css属性position的属性值有哪些,描述它们的作用 3.常见的浏览器端的存储技术有哪些,以及它们的优缺点 4.程序定义如下: v ...

  5. 使用 CSS3 绘制 Hello Kitty

    偶然间看到了 SegmentFault 上的一篇文章,感觉这个 Hello Kitty 画的还不错,心血来潮也用 CSS3 画了个 Hello Kitty,现在在这里记录一下详细的绘制过程.想要源码. ...

  6. AspNet MVC中各种上下文理解

    0  前言 AspNet MVC中比较重要的上下文,有如下: 核心的上下文有HttpContext(请求上下文),ControllerContext(控制器上下文) 过滤器有关有五个的上下文Actio ...

  7. App开发(Android与php接口)之:短信验证码

    最近和同学们一起开发一个自主项目,要用到短信验证码,在网上搜索了很久,看到一个推荐贴,提到了很多不错的短信服务商.经过测试,帖子中提到的服务商他们的短信到达率和到达速度也都不错.最后,由于经费问题,我 ...

  8. 用SignalR实现的共享画板例子

    使用HTML5的canvas画布功能,在页面进行绘画,然后通过SignalR将画布的每个点的颜色提交到服务端,服务端同时将这些画布的信息推送到其他客户端,实现共享同一个画板的功能 类似下图,在某一个浏 ...

  9. Android手机_软件01

    1.微信 下载:http://weixin.qq.com/ 2.QQ 下载:http://im.qq.com/download/ 3.滴滴打车(乘客端):http://www.xiaojukeji.c ...

  10. 红包demo

    嘿嘿,红包demo import random dic={} lis=['KeLan','MonKey','Dexter','Superman','Iron Man','Robin'] def red ...