锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲AV永久无码精品水牛影视 ,亚洲中文无码av永久,国产精品亚洲一区二区麻豆http://blogjava.net/silvermyth/category/55192.htmlzh-cnMon, 10 Apr 2017 07:12:53 GMTMon, 10 Apr 2017 07:12:53 GMT60JQuery鎻掍歡緙栧啓紺轟緥http://m.tkk7.com/silvermyth/articles/432432.htmlGavin LiGavin LiWed, 05 Apr 2017 09:35:00 GMThttp://m.tkk7.com/silvermyth/articles/432432.htmlhttp://m.tkk7.com/silvermyth/comments/432432.htmlhttp://m.tkk7.com/silvermyth/articles/432432.html#Feedback0http://m.tkk7.com/silvermyth/comments/commentRss/432432.htmlhttp://m.tkk7.com/silvermyth/services/trackbacks/432432.html     瑕佹兂緙栧啓涓涓狫query鎻掍歡錛岄鍏堝繀欏誨Jquery鏈夋墍浜?jiǎn)瑙eQ屽挨鍏舵槸浠ヤ笅鍑犱釜鐭ヨ瘑鐐癸細(xì)
  •     鐭ラ亾錛坒unction($){...}錛?jQuery)鏄粈涔堟剰鎬?br /> 錛坒unction($){...}錛?jQuery)瀹氫箟浜?jiǎn)涓涓嚱鏁幫紝騫朵笖浠Query涓哄弬鏁拌繘琛屼簡(jiǎn)璋冪敤錛屼竴鑸儏鍐典笅錛岃繖鏄疄鐜癹Query鎻掍歡鐨勬爣鍑嗗Э鍔匡紝瀵硅繖涓湁鍏磋叮鐨勫悓瀛﹀彲浠ョ戶緇繁鍏ョ爺絀躲?br />
  •     $.proxy(fun, context)
    璇ユ柟娉曡繑鍥炰竴涓猣un鍑芥暟鐨勪唬鐞嗭紝榪斿洖鐨勪唬鐞嗗嚱鏁板姛鑳藉拰fun鐩稿悓錛屼笉鍚岀殑鏄繑鍥炲嚱鏁頒嬌鐢╟ontext鍙傛暟浣滀負(fù)璋冪敤涓婁笅鏂囥傝繖孌佃瘽鏈夌偣緇曞彛錛屼笉鏄庣櫧鐨勫悓瀛﹁鍙傝冿細(xì)
    http://www.cnblogs.com/hongchenok/p/3919497.html
  •     $.each(arr, function(){...})
    璇ユ柟娉曞湪姣忎釜arr涓殑鍏冪礌涓婃墽琛宑allback鏂規(guī)硶錛屽瓨鍦ㄥ緢澶氬彉浣撱傝緇嗚鍙傝http://www.jb51.net/article/24581.htm
  •     $.extend(deep, obj, obj1, ..)
    Jquery鎻愪緵鐨勭敤鏉ユ墿灞曚竴涓璞$殑鏂規(guī)硶錛屽嵆灝嗗璞bj1鍚堝茍鍒板璞bj錛屼竴鑸鐢ㄦ潵鍚慾Query瀵硅薄涓坊鍔犳柟娉曘傝緇嗚鍙傝僪ttp://www.cnblogs.com/tianguook/p/4084061.html
  •     $.data(dom, data-name, data-value)
    Jquery鎻愪緵鐨勭敤鏉ョ粦瀹氬璞″埌dom瀵硅薄涓殑鏂規(guī)硶錛屽鏋滄病鏈夊畾涔塪ata-value鍙傛暟錛屾槸璇誨彇data-name鐨勫鹼紱濡傛灉瀹氫箟浜?jiǎn)data-value鍒欐槸璁劇疆data-name鐨勫箋?br />
      鏈変簡(jiǎn)浠ヤ笂鐭ヨ瘑錛屾垜浠潵瀹炵幇涓涓猄elect鐨凧query鎻掍歡錛屽彲浠ユ柟渚跨殑鍒涘緩銆佹坊鍔犻夐」銆佸垹闄ら夐」絳夌瓑銆備唬鐮佸涓嬶細(xì)
    /**
 * Created by gavinli on 17-3-30.
 
*/
;(function ($) {
    'use strict';

    var pluginName = 'myList';

    var _default = {};

    _default.settings = {};

    var MyList = function (element, options) {
        this.$element = $(element);
        this.init(options);
        return {
            init: $.proxy(this.init, this),
            add: $.proxy(this.add, this),
            remove: $.proxy(this.remove, this),
            list: $.proxy(this.list, this),
            clear: $.proxy(this.clear, this),
            getSelected: $.proxy(this.getSelected, this)
        }
    };

    MyList.prototype.init = function (options) {
        this.items = [];

        if (options.data) {
            if (typeof options.data === 'string') {
                options.data = $.parseJSON(options.data);
            }
            this.items = $.extend(true, [], options.data);
            delete options.data;
        }
        this.options = $.extend({}, _default.settings, options);
        this.render();
        this.subscribeEvents();
    };

    MyList.prototype.subscribeEvents = function () {
        //TODO:
    };

    MyList.prototype.add = function (items) {
        if (!(items instanceof Array)) {
            items = [items];
        }
        var _this = this;
        $.each(items, function (i, value) {
            _this.items.push(value);
        });
        this.filterDup();
        this.render();
    }

    //Remove all duplicated items
    MyList.prototype.filterDup = function () {
        var _this = this;
        var values = {}
        $.each(_this.items, function (i, value) {
            if (values[value]) {
                _this.items[i] = null;
            } else {
                values[value] = true;
            }
        });
    }

    MyList.prototype.remove = function (items) {
        var _this = this;
        var toBeRemoved = {};
        $.each(items, function (i, value) {
            toBeRemoved[value] = true;
        });
        $.each(_this.items, function (i, value) {
            if (toBeRemoved[value] == true) {
                _this.items[i] = null;
            }
        });
        this.render();
    }

    MyList.prototype.getSelected = function () {
        return this.$wrapper.val();
    }

    MyList.prototype.list = function (item) {
        var result = [];
        $.each(this.items, function (i, value) {
            if (value) {
                result.push(value);
            }
        });
        return result;
    }

    //Clear all items
    MyList.prototype.clear = function () {
        delete this.items;
        this.items = [];
        this.render();
    }

    MyList.prototype.render = function () {
        if (!this.initialized) {
            this.$wrapper = $(this.template.list);
            this.initialized = true;
        }
        //Append select element to $element
        this.$element.empty().append(this.$wrapper.empty());

        //Build select options
        this.buildList(this.items);
    }

    MyList.prototype.buildList = function (items) {
        var _this = this;
        $.each(items, function (i, value) {
            if (value) {
                var option = $(_this.template.item);
                option.append(value);
                _this.$wrapper.append(option);
            }
        });
    }

    MyList.prototype.template = {
        list: '<select multiple class="form-control"></select>',
        item: '<option></option>'
    };

    $.fn[pluginName] = function (options, args) {
        var result;
        this.each(function () {
            var _this = $.data(this, pluginName);
            if (typeof options === 'string') {
                if (!_this) {
                    //logError('Not initialized, can not call method : ' + options);
                }
                else if (!$.isFunction(_this[options]) || options.charAt(0) === '_') {
                    //logError('No such method : ' + options);
                }
                else {
                    if (!(args instanceof Array)) {
                        args = [args];
                    }
                    result = _this[options].apply(_this, args);
                }
            }
            else if (typeof options === 'boolean') {
                result = _this;
            }
            else {
                $.data(this, pluginName, new MyList(this, $.extend(true, {}, options)));
            }
        });
        return result || this;
    };

})(jQuery);
    涓嬮潰閽堝鍏朵腑鐨勫叧閿柟娉曡繘琛屽垎鏋愯瑙o細(xì)
    MyList鍑芥暟錛歁yList瀵硅薄鐨刢onstrunctor鏂規(guī)硶錛屾帴鍙梠ptions鍙傛暟錛坥ptions鍙傛暟鍖呭惈鎵鏈塷ptions鐨勬暟緇勶級(jí)
    MyList.prototype.init錛氭牴鎹畂ptions鐨刣ata鏋勫緩騫舵覆鏌揝elect鎺т歡
    MyList.prototype.add錛氭坊鍔爋ption鍒癝elect涓茍娓叉煋錛屽叾瀹價(jià)emove錛宭ist錛実etSelected鏂規(guī)硶澶у鑷鐮旂┒
    涓婇潰浠g爜涓紝鏈鏍稿績(jī)鐨勯儴鍒嗗湪浜庡浣曞皢MyList瀵硅薄鍜孌om鍏冪礌緇撳悎銆佸茍涓旀墿灞曞埌Jquery涓紝鍏蜂綋鍙傝冨涓嬫敞閲婁唬鐮侊細(xì)
    ////鎵╁睍jQuery鐨刾rototype瀵硅薄錛岃繖閲岀殑plugName絳変簬myList錛岀浉褰撲簬緇檍Query瀵硅薄娣誨姞浜?jiǎn)涓涓?myList"鏂規(guī)硶
    $.fn[pluginName] = function (options, args) { 
        var result;
        ////榪欓噷鐨則his鏄竴涓猨Query瀵硅薄
        this.each(function () {    
            //涓嬮潰鐨則his涓嶆槸jQuery瀵硅薄錛岃屾槸jQuery瀵硅薄涓殑Dom瀵硅薄
            //浠嶥om瀵硅薄涓幏鍙?data-myList"灞炴х粦瀹氱殑瀵硅薄
            var _this = $.data(this, pluginName);
            //options鏄柟娉曞悕錛屼緥濡?('#list1').MyList('add'錛孾])錛岃繖閲岀殑options絳変簬'add'
            if (typeof options === 'string') {
                if (!_this) {
                    //logError('Not initialized, can not call method : ' + options);
                }
                else if (!$.isFunction(_this[options]) || options.charAt(0) === '_') {
                    //logError('No such method : ' + options);
                }
                else {
                    if (!(args instanceof Array)) {
                        args = [args];
                    }
                    //璋冪敤MyList瀵硅薄鐨勬柟娉?/span>
                    result = _this[options].apply(_this, args);
                }
            }
            else if (typeof options === 'boolean') {
                result = _this;
            }
            else {
                //鍒涘緩MyList瀵硅薄騫剁粦瀹氬埌Dom瀵硅薄鐨刣ata-myList灞炴?/span>
                $.data(this, pluginName, new MyList(this, $.extend(true, {}, options)));
            }
        });
        return result || this;
    };
   濡備綍浣跨敤璇ユ彃浠剁殑鏂規(guī)硶濡備笅鎵紺猴細(xì)
    棣栧厛鍦╤tml涓畾涔変竴涓?lt;div id="list1"></div>錛岀劧鍚庤繖鏍蜂嬌鐢ㄥ畠錛?br />     //鍒涘緩涓涓猄elect鍖呭惈涓変釜options
$('#list1').MyList(['Tom','Mary','Alice']);
//娣誨姞鏂扮殑option
$('#list1').MyList('add', [['James','Richard']]);
//鍒犻櫎option
$('#list1').MyList('remove', [['Alice']]);
    鏈鍚庢垜浠彲浠ュ湪浠ヤ笂渚嬪瓙涓彂鐜板垱寤簀Query鎻掍歡鐨勬諱綋鎬濊礬錛?br />
  •     鑷畾涔夊璞★紝瀵硅薄涓寘鍚暟鎹拰jQuery瀵硅薄鏈韓
  •     瀹氫箟瀵硅薄鐨勬柟娉曪紝騫朵笖鏍規(guī)嵁瀵硅薄涓暟鎹殑鍙樺寲娓叉煋Dom瀵硅薄錛堥氳繃jQuery瀵硅薄鑾峰緱Dom瀵硅薄錛?/li>
  •     灝嗚鑷畾涔夊璞℃柟娉曟墿灞曞埌jQuery鍘熷瀷瀵硅薄涓?/li>
  •     鍒涘緩鑷畾涔夊璞★紝騫剁粦瀹氬埌jQuery涓璂om瀵硅薄鐨刣ata灞炴?br />
    閫氳繃浠ヤ笂瀹炵幇錛屾垜浠究鍙互鍍忎嬌鐢╦Query瀵硅薄涓鏍風(fēng)殑鏂瑰紡浣跨敤鎺т歡錛屽睆钄藉Dom鍏冪礌鐨勬搷浣滐紝綆鍗曞張鏂逛究

Gavin Li 2017-04-05 17:35 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲av日韩专区在线观看| 亚洲字幕在线观看| 尤物视频在线免费观看| 日韩高清在线高清免费| 亚洲日韩精品A∨片无码加勒比| 美女视频黄的全免费视频网站| 亚洲另类春色校园小说| 国产曰批免费视频播放免费s| 亚洲国产精品综合久久久| 57PAO成人国产永久免费视频| 亚洲小说图片视频| 免费理论片51人人看电影| 亚洲AⅤ男人的天堂在线观看| 亚洲精品国产福利片| 久久免费线看线看| 亚洲视频一区在线| 桃子视频在线观看高清免费完整| 亚洲一区免费视频| 日韩一级免费视频| 一级**爱片免费视频| 午夜亚洲国产理论秋霞| 国产福利在线观看免费第一福利| 亚洲ts人妖网站| 国产黄色片在线免费观看| 成人免费网站视频www| 亚洲av无码乱码国产精品fc2| 亚洲人成免费网站| 亚洲妇女无套内射精| 国产精品亚洲综合专区片高清久久久| av午夜福利一片免费看久久| 亚洲AV无码久久寂寞少妇| 国产免费看JIZZ视频| 色视频在线观看免费| 久久综合图区亚洲综合图区| 久草在视频免费福利| 一级一级毛片免费播放| 亚洲午夜电影在线观看| 亚洲情侣偷拍精品| 2020久久精品国产免费| 曰韩无码AV片免费播放不卡| 亚洲图片校园春色|