Jquery - 如果页面已加载 [英] Jquery - if page loaded
本文介绍了Jquery - 如果页面已加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何技巧如何在javascript中启动一个函数,该函数在页面完全加载时启动?
Is there any trick how to start a function in javascript, which starts when the page is completely loaded?
推荐答案
如果你的意思是当HTML文档加载时,使用 ready
事件:
If you mean when the HTML document has loaded, use the ready
event:
$(document).ready(function(){
...
});
或简写:
$(function(){
...
});
如果您的意思是包含所有样式表,脚本,图像和诸如此类的页面已完成加载,请使用加载
事件:
If you mean when the page including all style sheets, scripts, images and whatnot has completed loading, use the load
event:
$(window).load(function(){
...
});
这篇关于Jquery - 如果页面已加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文