Advertisement
Guest User

RM_TOC

a guest
May 28th, 2023
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.90 KB | None | 0 0
  1. function turn_rm_toc_collapsable() {
  2.     ?>
  3.     <script>
  4.         jQuery(document).ready(function() {
  5.             var tocItems = jQuery("div.wp-block-rank-math-toc-block");
  6.             tocItems.bind("click", function(event) {
  7.                 var nav = jQuery(this).find("nav");
  8.                 var tocHeading = jQuery(this).find("h2");
  9.                 if (nav.css("overflow") == "hidden") {
  10.                     nav.css("overflow", "visible");
  11.                     nav.css("max-height", "100vh");
  12.                     tocHeading.addClass("active"); // Add the "active" class
  13.                 } else {
  14.                     nav.css("overflow", "hidden");
  15.                     nav.css("max-height", "0");
  16.                     tocHeading.removeClass("active"); // Remove the "active" class
  17.                 }
  18.             });
  19.         });
  20.     </script>
  21.     <?php
  22. }
  23. add_action('wp_footer', 'turn_rm_toc_collapsable');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement