0
votes

I am trying to convert bootastap 4 accordion on hover and yes I did but exactly not working as expected.

here is my code

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

and here is the codepen

1
try this ` $('.accordion .card-header button').on('mouseenter', function(event) { $(this).parent().parent().next('div').collapse('show'); })`amar9312
@tphobe9312 will you please elaborate what I have done worng because your answer seems to workOwaiz Yusufi
u were not using thisamar9312
@tphobe9312 thanks for telling my mistake so stupid I amOwaiz Yusufi

1 Answers

1
votes

Here's a less verbose approach...

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

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