• js


    (function(){
    var bds = {
    util: {}
    };
    var c = document.getElementById('kw').parentNode;

    bds.util.getWinWidth = function(){
        return window.document.documentElement.clientWidth;
    };
    
    bds.util.setFormWidth = function(){
        var width = bds.util.getWinWidth();
        if(width < 1217)    {bds.util.setClass(c, 'ip_short', 'add')}
        else                {bds.util.setClass(c, 'ip_short', 'remove')};
    };
    
    bds.util.setClass = function(obj, class_name, set) {
        var ori_class = obj.className,
            has_class_p = -1,
            ori_class_arr = [],
            new_class = '';
    
        if(ori_class.length) ori_class_arr = ori_class.split(' ');
    
        for( i in ori_class_arr) {
            if(ori_class_arr[i] == class_name) has_class_p = i;
        }
    
        if( set == 'remove' && has_class_p >= 0) {
            ori_class_arr.splice(has_class_p, 1);
            new_class = ori_class_arr.join(' ');
            obj.className = new_class;
        } else if( set == 'add' && has_class_p < 0) {
            ori_class_arr.push(class_name);
            new_class = ori_class_arr.join(' ');
            obj.className = new_class;
        }
    }
    bds.util.setFormWidth();
    
    if (typeof document.addEventListener != "undefined") {
        window.addEventListener('resize', bds.util.setFormWidth, false);
        document.getElementById('kw').addEventListener('focus', function(){bds.util.setClass(c,'iptfocus', 'add');}, false);
        document.getElementById('kw').addEventListener('blur', function(){bds.util.setClass(c,'iptfocus', 'remove');}, false);
    } else {
        window.attachEvent('onresize', bds.util.setFormWidth, false);
        document.getElementById('kw').attachEvent('onfocus', function(){bds.util.setClass(c,'iptfocus', 'add');}, false);
        document.getElementById('kw').attachEvent('onblur', function(){bds.util.setClass(c,'iptfocus', 'remove');}, false);
    } 
    

    })();

        //</script>
  • 相关阅读:
    LeetCode_Spiral Matrix II
    省选模拟10 题解
    省选模拟9 题解
    省选模拟8 题解
    省选模拟7 题解
    省选模拟6 题解
    省选模拟5 题解
    省选模拟4 题解
    数学专题测试3 题解
    数学专题测试2 题解
  • 原文地址:https://www.cnblogs.com/ITniu/p/6776325.html
Copyright © 2020-2023  润新知