我可以在单个html页面中多次使用jquery的$(document).ready()吗?

我有一个名为“text.html”的html页面
<html>
    <body>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="js/Photos.js"></script>
        <script type="text/javascript" src="js/Animations.js"></script>
    </body>
</html>

Photos.js和Animations.js都以“$(document).ready()”开头

//Javascript File Photos.js
$(document).ready(function() {
    //My code here ....
});

//Javascript File Animations.js
$(document).ready(function() {
    //My code here ....
});

如果我在单个html页面中使用多个$(document).ready(function(){是否重要?

提前致谢

解决方法

您可以根据需要使用多个,但为了便于阅读,最好将其保留为一个.

还要考虑使用short hand $(function(){…});

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些