How can I fade out a div using jQuery?

前端 未结 7 1973
孤街浪徒
孤街浪徒 2020-12-05 09:46

Is there any way to fadeout a div after 5 Seconds without using a setTimeOut function?

7条回答
  •  青春惊慌失措
    2020-12-05 10:12

    Not sure if you want it to take 5 seconds or start in 5 seconds.

    For it to take 5 seconds: The jQuery fadeout function can be used on a div, and it will reduce the element's opacity until it is 0 and then display none the div. The speed of the fade is a parameter for the function.

    http://docs.jquery.com/Effects/fadeOut#speedcallback

    To start it in 5 seconds, you'll need some sort of timer that starts when the document or window is ready, or when the div is ready depending on what you want.

提交回复
热议问题