加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap – Bootstrap 3,在悬停时打开Collapse元素

发布时间:2020-12-17 21:25:46 所属栏目:安全 来源:网络整理
导读:我正在尝试将一些代码从Bootstrap 2转换为Bootstrap 3: $(document).on('mouseenter.collapse.data-api','[data-toggle=collapse]',function(e) { var $this = $(this),href,target = $this.attr('data-target') || e.preventDefault() || (href = $this.at
我正在尝试将一些代码从Bootstrap 2转换为Bootstrap 3:

$(document).on('mouseenter.collapse.data-api','[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).data('collapse') ? 'show' : $this.data()
        $(target).collapse(option)
});

看起来他们从v2>改变了很多东西. v3,所以我对改变什么感到有点失落.我找到了一个有点处理它的线程,但实际上并没有做我想要的事情:

Bootstrap Collapse accordion on hover

基本上我需要在折叠中有x个元素.当您将鼠标悬停在其中一个上时,它会将其打开(而不是必须单击它).然后当你移动另一个时,它会关闭其他的并打开新的.

谢谢你的任何建议!

解决方法

我编辑了以下脚本以使其工作

$(function() {
    $(document).on('mouseenter.collapse',function(e) {
        var $this = $(this),''),option = $(target).hasClass('in') ? 'hide' : "show";
            $('.panel-collapse').not(target).collapse("hide");
            $(target).collapse(option);
    })
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读