Why is $(document).ready needed after the [removed] tag?

前端 未结 3 640
攒了一身酷
攒了一身酷 2020-12-06 12:51

Why is $(document).ready needed after the

3条回答
  •  北海茫月
    2020-12-06 13:27

    Why is $(document).ready really need after

    That div will not be shown, because it doesn't exist when the code runs. So people use ready to delay their code.

    There's a better way if you control where your script tags go: Just put your script tag at the end of the document, just before the closing tag:

    
    
    
    
    

    All of the elements defined above the script tag will exist when the code runs. No need for ready.

提交回复
热议问题