zoukankan      html  css  js  c++  java
  • IE 8-不支持 placeholder 解决方法

            ;!function fixPlaceholder() {
                var hasPlaceholder = 'placeholder' in document.createElement('input');
                if(!hasPlaceholder) {
                    $(document).on('blur', '[placeholder]', function () {
                        if($(this).val() == '') {
                            $(this).val($(this).attr('placeholder'))
                        }
                    }).on('focus', '[placeholder]', function () {
                        var $this = $(this);
                        if($this.val() == $this.attr('placeholder')) {
                            var r = $this.createTextRange();
                            r.collapse(true);
                            r.select();
                            if (typeof($this.onselectstart) != "undefined") {
                                // IE下禁止元素被选取
                                $this.onselectstart = new Function("return false");
                            }
                        }
    
                    }).on('keydown','[placeholder]', function () {
                        var $this = $(this);
                        if($this.val() == $this.attr('placeholder')) {
                            $this.val('');
                        }
    
                        if (typeof($this.onselectstart) != "undefined") {
                            // IE下禁止元素被选取
                            $this.onselectstart = new Function("return false");
                        }
                    });
    
                    $('[placeholder]').blur();
                }
            }();
    
    
  • 相关阅读:
    psy & vr
    psy 2
    psy
    linux c中select使用技巧
    hostent h_addr_list
    gethostbyname() -- 用域名或主机名获取IP地址
    c_select 调用参数说明
    [NYOJ 737] 石子合并(一)
    [HDU 1059] Dividing
    [HDU 1789] Doing Homework again
  • 原文地址:https://www.cnblogs.com/fayin/p/6598845.html
Copyright © 2011-2022 走看看