JAVASCRIPT   65

script js

Guest on 24th May 2022 01:09:10 AM

  1. // When a question is clicked
  2. $('.question').on('click', function () {
  3.   // If the question clicked is NOT open.
  4.   if (!$('#' + $(this).data('resp_id')).hasClass('resp_act')) {
  5.     // I close the one that is open, if there is one
  6.     $('.ico_resp').removeClass('ico_resp_act');
  7.     $('.resp_act').css('height', 0);
  8.     $('.resp_act').removeClass('resp_act');
  9.     // Open the question that was clicked
  10.     $('#' + $(this).data('resp_id')).css('height', $('#sp_' + $(this).data('resp_id')).height() + ' px');
  11.     $('#' + $(this).data('resp_id')).addClass('resp_act');
  12.     $('i', this).addClass('ico_resp_act');
  13.   // Else, if the question is already open
  14.   } else {
  15.     // I close it
  16.     $('.ico_resp').removeClass('ico_resp_act');
  17.     $('.resp_act').css('height', 0);
  18.     $('.resp_act').removeClass('resp_act');
  19.   }
  20. });

Raw Paste


Login or Register to edit or fork this paste. It's free.