How to create cookie banner with close button?

Hi everyone!

I am trying to create a cookie banner using components.html, but cannot get the close button to work. Do you know how to make this work? Thanks in advance.

Code:

    components.html(
    f"""
        <script>
            window.parent.document.querySelector('.cookie-banner').delay(2000).fadeIn();
            window.parent.document.querySelector('.close-button').click(function() {{window.parent.document.querySelector('.cookie-banner').fadeOut();}});
        </script>
    """,height=0)