由于$(document).ready,Jquery函数无法正常工作 [英] 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 >。
call test-1.js before test-2.js .
示例
<script type="text/javascript" src="test-1.js"></script>
<script type="text/javascript" src="test-2.js"></script>
这篇关于由于$(document).ready,Jquery函数无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文