Bootstrap Collapse accordion on hover

前端 未结 7 1971
轮回少年
轮回少年 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

    I achieved hover functionality while maintaining 'clickability' fairly easily:

    jQuery(".pointer").hover(
        function(){
            var thisdiv = jQuery(this).attr("data-target")
            jQuery(thisdiv).collapse("show");
        },
        function(){
            var thisdiv = jQuery(this).attr("data-target")
            jQuery(thisdiv).collapse("hide");
        }
    );
    

    I was already using the data-attributes, so I kept them, and used them here to trigger the right divs. "pointer" is a class on my toggle links, so you can adapt that to whatever you need.

提交回复
热议问题