JavaScript - Hide a Div at startup (load)

前端 未结 6 1767
南方客
南方客 2020-12-29 03:17

I have a div in my php page that uses jQuery to hide it once the page has loaded. But is there a way to hide it from the very start of loadup?

The reason I ask is be

6条回答
  •  长情又很酷
    2020-12-29 03:40

    Barring the CSS solution. The fastest possible way is to hide it immediatly with a script.

    In this case I would recommend the CSS solution by Vega. But if you need something more complex (like an animation) you can use this approach.

    This has some complications (see comments below). If you want this piece of script to really run as fast as possible you can't use jQuery, use native JS only and defer loading of all other scripts.

提交回复
热议问题