Advertisement
jaideep06

TOC Collapse

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