Show a section only if after button selection

This topic has 2 replies, 2 voices, and was last updated 1 month ago ago by Samir Malik

  • Avatar: Wences
    Wences
    Participant
    February 10, 2026 at 20:55

    Hello,

    Is it possible to show a section only if button (in the page) is selected?

    Thank you,

    1 Answer
    Avatar: Samir Malik
    Samir Malik
    Support staff
    February 11, 2026 at 06:05

    Hello,

    This can be achieved using custom JavaScript and CSS code.

    1. Section CSS Class (Elementor UI)
    Go to: Section → Advanced → CSS Classes
    Add the following class:
    reveal-section

    2. Button CSS Class (Elementor UI)
    Go to: Button → Advanced → CSS Classes
    Add the following class:
    reveal-btn

    3. CSS (to hide the section by default)
    Add the following code under Appearance → Customize → Additional CSS
    (or Elementor → Site Settings → Custom CSS):

    
    .reveal-section {
        display: none;
    }
    

    4. JavaScript (to display the section when the button is clicked)
    Add the following code via Elementor → Custom Code (Footer)
    or in an HTML widget:

    
    <script>
    document.addEventListener("DOMContentLoaded", function () {
        document.querySelectorAll(".reveal-btn").forEach(function (btn) {
            btn.addEventListener("click", function () {
                const section = document.querySelector(".reveal-section");
                if (!section) return;
    
                section.style.display = "block";
                btn.style.display = "none"; // optional: hide button after click
            });
        });
    });
    </script>
    
    

    Best regards,
    8Theme Team

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.