JAVASCRIPT
65
script js
Guest on 24th May 2022 01:09:10 AM
// When a question is clicked
$('.question').on('click', function () {
// If the question clicked is NOT open.
if (!$('#' + $(this).data('resp_id')).hasClass('resp_act')) {
// I close the one that is open, if there is one
$('.ico_resp').removeClass('ico_resp_act');
$('.resp_act').css('height', 0);
$('.resp_act').removeClass('resp_act');
// Open the question that was clicked
$('#' + $(this).data('resp_id')).css('height', $('#sp_' + $(this).data('resp_id')).height() + ' px');
$('#' + $(this).data('resp_id')).addClass('resp_act');
$('i', this).addClass('ico_resp_act');
// Else, if the question is already open
} else {
// I close it
$('.ico_resp').removeClass('ico_resp_act');
$('.resp_act').css('height', 0);
$('.resp_act').removeClass('resp_act');
}
});