关闭动画下拉列表

时间:2015-12-17 14:44:05

标签: javascript jquery css

我想添加一个听取点击' html'然后关闭下拉列表。它只能在没有puttind css显示的hide函数的情况下工作。似乎什么都没有用!! 有什么想法吗?

// Drop Down Menu
EZEMAIN.dropDown = {
    slideTime: 200,
    dropDown: '.dn-drop-down',
    arrow: '.dn-menu-arrow',
    arrowUp: 'dn-arrow-up',

    bindElms: function () {
        this.btn = $('.dn-dropdown-btn');
    },

    html: function(e) {



    },

    showHide: function (e) {
        var self = EZEMAIN.dropDown,
            dropDown = $(this).find(self.dropDown),
            arrow = $(this).find(self.arrow),
            openedDropDowns = $(self.dropDown).is(':visible');


        if ($(e.target).parents(self.dropDown).length == 0)
            e.preventDefault();

        if (dropDown.is(':hidden')) {
            if (openedDropDowns) self.hide();

            dropDown.slideDown(self.slideTime, function () {
                arrow.addClass(self.arrowUp);
            });

            setTimeout(function () {
                $('body').on('click', self.hide);
            }, 100);
        }
        else
            self.hide();
    },

    hide: function () {
        var self = EZEMAIN.dropDown;

        $(self.dropDown).slideUp(self.slideTime, function () {

            $(self.arrow).filter(function () { return $(this).siblings('.dn-basket-btn').length == 0; }).removeClass(self.arrowUp);
        });


        $("html").click(function () {


            //$("#dn-header-basket").css("display", "none");
            $(EZEMAIN.arrow).filter(function () { return $(this).siblings('.dn-menu-arrow').length == 0; }).removeClass(self.arrowUp);
        });

        $('body').off('click', self.hide);
    },



    init: function () {
        this.bindElms();
        this.btn.click(this.showHide);
    }
};

0 个答案:

没有答案