本文介紹了由于 $(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 函數無法正常工作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!