$(document).ready()

Using $(document).ready() is almost always preferable to using an
onload handler, but we need to keep in mind that because supporting
files may not have loaded, attributes such as image height and width are
not necessarily available at this time. If these are needed, we may at times also choose to implement an onload handler (or more likely, jQuery's .load() equivalent); the two mechanisms can coexist peacefully.

你可能感兴趣的:(jquery)