jquery ready函数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangjun5159/article/details/79289528

jquery ready函数指的是
$(document).ready(function);它等同于$(function(){})
不过有经验的工程师,简便起见,更喜欢使用 $(function(){})
jquery ready函数在DOM元素渲染完后触发,不包括外部资源(img、iframe)的加载完毕。
如果想在资源(img、iframe)加载完毕后触发事件,则使用$(window).on("load",function(){})

A page can’t be manipulated safely until the document is “ready.” jQuery detects this state of readiness for you. Code included inside $( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside \$( window ).on( “load”, function() { … }) will run once the entire page (images or iframes), not just the DOM, is ready.

参考

$( document ).ready()

猜你喜欢

转载自blog.csdn.net/wangjun5159/article/details/79289528