show video after completing gravity form

I have a page with a button. When the user clicks on the button, a pop-up should open and he should enter his contact number using gravity form and then the video will be shown to him.
Now I have a button on the page and an html element that displays the video through the iframe tag, and the default mode is display: none.

function custom_script() {
        ?>
        <script type="text/javascript">
      document.addEventListener('DOMContentLoaded', function () {
        // Event listener for form submission
        jQuery(document).on('gform_confirmation_loaded', function(event, formId){
            // Check if the submitted form is the one with ID 1
            if (formId == 1) {
                // Show the video element with ID 'wb-video'
                document.getElementById('wb-video').style.display = 'block';
            }
        });
    });
    
        </script>
        <?php
    }
    add_action('wp_footer', 'custom_script');

I put this code at the end of the functions.php file. But after the user completes the form, nothing happens on the page. The video is not displayed.
Thank you if you guide me.