Home / Admin / On Scroll Elementor show/hide element
Duplicate Snippet

Embed Snippet on Your Site

On Scroll Elementor show/hide element

Note: You need to set the id for the button or element to "#scrolling-button".

Code Preview
php
<?php
function custom_header_button_script() {
    ?>
    <style>
        #scrolling-button {
            display: none;
        }
    </style>
    <script>
        jQuery(document).ready(function($) {
            $(window).scroll(function() {
                var scroll = $(window).scrollTop();
                if (scroll >= 50) {
                    $("#scrolling-button").fadeIn(200); // fadeIn duration
                } else {
                    $("#scrolling-button").fadeOut(200); // fadeOut duration
                }
            });
        });
    </script>
    <?php
}
add_action('wp_head', 'custom_header_button_script');

Comments

Add a Comment