Bootstrap Collapse accordion on hover

前端 未结 7 1970
轮回少年
轮回少年 2020-12-16 17:40

I\'m using Twitter\'s Bootstrap \'Collapse\' plug-in in a project I am working on. I have a simple accordion (setup as per the documentation), but I want to amend the defaul

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 18:13

    to put it to work for bootstrap3 i made some changes

    $(function() {
        $(document).on('mouseenter.collapse', '[data-toggle=collapse]', function(e) {
            var $this = $(this),
                href, 
                target = $this.attr('data-target') 
                         || e.preventDefault() 
                         || (href = $this.attr('href')) 
                         && href.replace(/.*(?=#[^\s]+$)/, ''), //strip for ie7
                option = $(target).hasClass('in') ? 'hide' : "show"
    
                $('.panel-collapse').not(target).collapse("hide")
                $(target).collapse(option);
        })
    });
    

提交回复
热议问题