JS仿百度搜索自动提示框匹配查询功能(9)

var targetInput = $(_config.targetCls,targetParent);
             if($(targetInput).attr('up') || $(targetInput).attr('down')) {
                 $(targetInput).attr('up') && $(targetInput).removeAttr('up');
                 $(targetInput).attr('down') && $(targetInput).removeAttr('down');
             }
             _config.closedCallback && $.isFunction(_config.closedCallback) && _config.closedCallback();
          });
    },
    /*
     * 数组去重复
     */
    _unique: function(arrs) {
        var obj = {},
            newArrs = [];
        for(var i = 0, ilen = arrs.length; i < ilen; i++) {
            if(obj[arrs[i]] != 1) {
                newArrs.push(arrs[i]);
                obj[arrs[i]] = 1;
            }
        }
        return newArrs;
    },
    /*
     * 输入框多选操作
     */
    _manySelect: function(targetParent) {
        var self = this,
            _config = self.config,
            _cache = self.cache;
        if(_cache.inputArrs.length > 0) {
            $(_config.targetCls,targetParent).val(_cache.inputArrs.join(','));
        }
    },
    /*
     * 判断是否是string
     */
     _isString: function(str) {
        return Object.prototype.toString.apply(str) === '[object String]';
     },
    /*
     * JS 动态添加css样式
     */
    _addStyleSheet: function(refWin, cssText, id){

        var self = this;
        if(self._isString(refWin)) {
            id = cssText;
            cssText = refWin;
            refWin = window;
        }
        refWin = $(refWin);
        var doc = document;
        var elem;

if (id && (id = id.replace('#', ''))) {
            elem = $('#' + id, doc);
        }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdwsys.html