Advertisement
jaideep06

Accordion

Feb 8th, 2023
907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. /**
  2.  * Convert Rank Math FAQ Block Into Accordion
  3.  */
  4. function turn_rm_faq_to_accordion() {
  5.     ?>
  6.     <script>
  7.         jQuery(document).ready(function() {
  8.             var faqBlock = jQuery("div#rank-math-faq");
  9.             var faqItems = faqBlock.find("div.rank-math-list-item");
  10.             faqItems.bind("click", function(event) {
  11.                 var answer = jQuery(this).find("div.rank-math-answer");
  12.                 if (answer.css("overflow") == "hidden") {
  13.                     answer.css("overflow", "visible");
  14.                     answer.css("max-height", "100vh");
  15.                 } else {
  16.                     answer.css("overflow", "hidden");
  17.                     answer.css("max-height", "0");
  18.                 }
  19.             });
  20.         });
  21.     </script>
  22.     <?php
  23. }
  24. add_action( 'wp_footer', 'turn_rm_faq_to_accordion' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement