Viewing 1 replies (of 1 total)
  • Thread Starter raits515

    (@raits515)

    I tired this javascript that i found from w3chools.com and changed the ‘get element glass name by class name’ but it’s still not working.

    function wp_customjs() {
    ?>
    <script>
    var acc = document.getElementsByClassName(“gs-faq__question”);
    var i;

    for (i = 0; i < acc.length; i++) {
    acc[i].addEventListener(“click”, function() {
    this.classList.toggle(“active”);
    var panel = this.nextElementSibling;
    if (panel.style.maxHeight) {
    panel.style.maxHeight = null;
    } else {
    panel.style.maxHeight = panel.scrollHeight + “px”;
    }
    });
    }
    </script>
    <?php
    }
    add_action( ‘wp_footer’, ‘wp_customjs’);

    Any help?

Viewing 1 replies (of 1 total)
  • The topic ‘Toggle Not Working Outside Loop’ is closed to new replies.