jQuery文档加载事件

  • $(document).ready(handler)
    $().ready(handler) (this is not recommended)
    $(handler)
    
    相当于:
    $(document).ready(function(){})
    $().ready(function(){}) (this is not recommended)
    $(function(){})
    

      只要DOM结构已完全加载时,脚本就可以运行。传递处理函数给.ready()方法,能保证DOM准备好后就执行这个函数,因此,这里是进行所有其它事件绑定及运行其它 jQuery 代码的最佳地方。

原文地址:https://www.cnblogs.com/shueixue/p/5741434.html