Jquery function is not working due to $(document).ready(由于 $(document).ready,Jquery 函数无法正常工作)
问题描述
我们有两个 js fie,test-1.js,test-2.js.
we have two js fie , test-1.js , test-2.js.
<script type="text/javascript" src="test-2.js"></script>
<script type="text/javascript" src="test-1.js"></script>
在 test-1.js 中的代码是
In test-1.js the code is
$(document).ready(function (){
function test_alert(){ alert("hiii"); }
});
在 test-2.js 中
In test-2.js
$(document).ready(function (){
function test_alert_2(){
test_alert();
alert("helloo");
}
});
但 test_alert() 在 test-2.js 中不起作用.如何解决这个问题?为什么这不起作用?
but test_alert() not working in test-2.js . How to solve this ? Why this is not working ?
为了解决这个问题,我重新安排了
to solve this i rearranged
<script type="text/javascript" src="test-1.js"></script>
<script type="text/javascript" src="test-2.js"></script>
现在也不行了.我无法删除 document.ready().
Now also , it is not working.I can not remove document.ready().
所以我需要一个不删除 document.ready() 的解决方案
So i need a solution without removing document.ready()
请帮忙.
推荐答案
在 test-2.js 之前调用 test-1.js.
示例
<script type="text/javascript" src="test-1.js"></script>
<script type="text/javascript" src="test-2.js"></script>
这篇关于由于 $(document).ready,Jquery 函数无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:由于 $(document).ready,Jquery 函数无法正常工作


基础教程推荐
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 动态更新多个选择框 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01