Triger multiple hiden rows

Hi there.
i have 4 buttons and each one shoul triger different hidden row. But when the user clicks on a button, the script should show him only the row associated with that button,and close the other rows.
I’m using this code right now but all the rows remain open if i click, it doesn-t close the previous one.

jQuery(document).ready(function($){
$(’.section-expandable’).slideToggle(0);
$(’.section-trigger’).on(‘click’,function(e){
e.preventDefault();
$(’.section-expandable’).slideToggle(‘slow’);
$(‘html, body’).animate({
scrollTop: $(".section-expandable").offset().top
}, 700, ‘swing’);
});
});

jQuery(document).ready(function($){
$(’.section-expandable-1’).slideToggle(0);
$(’.section-trigger-1’).on(‘click’,function(e){
e.preventDefault();
$(’.section-expandable-1’).slideToggle(‘slow’);
$(‘html, body’).animate({
scrollTop: $(".section-expandable-1").offset().top
}, 700, ‘swing’);
});
});

And same section-expandable-3 and 4 for the third and fourth button.
Thank you.

Hi There,

Please provide us with your website URL so we can take a closer look.

Thanks.

acontimo

and take a look at those two buttons ( Telefoane; Televizoare)
when u click on the second one, both remains opened.
I want the JS to close the first action when i click on the second button, and vice versa.

Thankyou…

Hi there,

It’s a bit tricky since you have different code for each button and it uses toggles, hence, harder to check its status from each button’s perspective. I would suggest contacting a developer and have your code consolidated as one and place button status (eg. active) then close whichever is active. Like how the accordion works.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.