WordPress DIVI: Show and hide elements with a button

Bildschirmfoto 2021 02 04 um 19.04.16
Contents

    1. create button via code

    Add a button with the class name “togglebtn” as shown in a screenshot

    <button class="togglebtn et_pb_button et_pb_button_2 et_pb_bg_layout_dark">Button Text</button>
    Bildschirmfoto 2021 02 04 um 19.03.53
    Wordpress DIVI: Show and hide elements with a button 5

    2. insert the CSS class into the element to be published

    The element to be hidden needs the following class:

    toggle-element
    Bildschirmfoto 2021 02 04 um 19.04.07
    Wordpress DIVI: Show and hide elements with a button 6

    3. additional code module with the Java Script function

    Inserts an additional code element to enable the Java Script function:

    <script>
    jQuery(document).ready(function($) {
          $ (".togglebtn").click(function () {
          $(".toggle-element").toggle(400);
        });
    });
    </script>
    
    Bildschirmfoto 2021 02 04 um 19.04.16
    Wordpress DIVI: Show and hide elements with a button 7

    Dieser Beitrag ist auch verfügbar auf: Deutsch (German)

    Updated on 29. March 2024
    Was this article helpful?

    Leave a Reply

    Your email address will not be published. Required fields are marked *