domready

javascript:how to write $(document).ready like event without jquery

回眸只為那壹抹淺笑 提交于 2019-11-26 06:34:59
问题 in jquery $(document).ready(function) or $(function) , how could I do the same thing without jquery, and I need browser compatiable, and allow to attach more than one function. Note: dom ready!= window onload 回答1: This is the way jQuery wraps the functions you're looking for - the snippet does not need jQuery, and is cross-browser compatible. I've replaced all calls to jQuery.ready() with yourcallback - which you need to define. What goes on in here: first, the function DOMContentLoaded is