• 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);
  • 相关阅读:
    目录(文章整理列表)
    WF工作流的一个完整例子
    WF的权限与角色(3)一个简单的权限体系结构
    工作流:工人为你工作7天,回报为一根金条...
    由一个WF项目说起
    软件是什么
    好久没发胡说八道的贴了,今天发一贴
    关于[资料(2).rar]的说明
    倒霉的3天
    DependencyProperty事件
  • 原文地址:https://www.cnblogs.com/LLJ748211490/p/6123375.html
Copyright © 2020-2023  润新知