Bootsrap 4-手风琴无法在悬停上工作/在悬停时无法正常工作

时间:2019-03-09 14:49:28

标签: jquery bootstrap-4 bootstrap-accordion

我正在尝试在悬停时转换bootastap 4手风琴,是的,但是确实没有按预期工作。

这是我的代码

$('.accordion .card-header button').on('mouseenter', function(event) {
    event.preventDefault();
    $( '.accordion .card' ).children('.collapse' ).collapse('show');
})

这是codepen

1 个答案:

答案 0 :(得分:1)

这是一种不太冗长的方法...

$('[data-toggle="collapse"]').on('mouseenter', function() {
    $(this).parents('.card').find('.collapse').collapse('show');
})

https://www.codeply.com/go/RNuEV348SQ