页面加载后如何进行jquery代码?

前端之家收集整理的这篇文章主要介绍了页面加载后如何进行jquery代码?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

If you want an event to work on your
page,you should call it inside the
$(document).ready() function.
Everything inside it will load as soon
as the DOM is loaded and before
the page contents are loaded.

我想在加载页面内容后才能执行JavaScript代码,我该怎么做?

解决方法

使用负载而不是准备好:
$(document).load(function () {
 // code here
});

更新 – 您需要使用$(window).on(‘load’,function(){… since jQuery 1.8.

this answer

According to 07001:

Removed deprecated event aliases

.load,.unload,and .error,deprecated since jQuery 1.8,are no
more. Use .on() to register listeners.

07002

原文链接:https://www.f2er.com/jquery/180139.html

猜你在找的jQuery相关文章