简体   繁体   中英

Short blink flashlight when loading the HTML page

I am new to Javascript and HTML, so please help me. My problem is next (you can watch it when loading my site https://treasure-island.fun ). So if u don't see the problem, I will explain: when you load the page you can see the blinking of all "donations" menus. In my JS code I have onLoad() function which hides all of the menus except one. But how can I make it stop blinking and flashing? Ty gyus.

This is the script that hides all

<script>
    function hide_all(id_not_to_hide){
        document.querySelectorAll('.donation').forEach(function(el) {
            el.style.visibility = 'hidden';
        });
        document.querySelectorAll(id_not_to_hide).forEach(function(el) {
            el.style.visibility = 'visible';
        });
    }
</script>

and this is my onload in tag:

<body onload="hide_all('#topographic-donation')">

Right now what you have is: your default state is that all .donation elements are visible. When the page is loaded, you hide all of them except one.

Just make the elements invisible by default and on body load, make that one single element visible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM