jQuery 未定义错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8373357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 10:26:30  来源:igfitidea点击:

jQuery is not defined error

jquery

提问by Justin John

Error in Jquery

Jquery 中的错误

In view file (index.php)

在视图文件 (index.php)

 <script type="text/javascript" src="crosscut.js" ></script> 
 <script src="jquery-ui.min.js" type="text/javascript"></script>
 <script type="text/javascript" src="mod-min.js" ></script>
 <script type="text/javascript" src="jquery-min.js" ></script>

In Javascript file

在 Javascript 文件中

$(document).ready(function() {
    $('#crossline').css('background-color','blue');
});

button = function() {
   // other code
}

I have included jquery-min.js in script and it is loaded on page loading. jquery-min.js all code loaded while inspecting through firebug .

我在脚本中包含了 jquery-min.js,它在页面加载时加载。jquery-min.js 通过 firebug 检查时加载的所有代码。

If file may be corrupted ,So I tried live path of "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" still not works.

如果文件可能已损坏,那么我尝试了“http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”的实时路径仍然无效。

If calling javascript function uses jquery works fine if ready function not set .

如果调用 javascript 函数使用 jquery 工作正常,如果就绪函数未设置。

回答by RightSaidFred

You're not providing much info, but one issue you have is that you're loading jQueryUIbeforeyou load jQuery.

你没有提供很多信息,但你有一个问题是,你加载jQueryUI之前加载jQuery

Any other files that rely on jQuery must be loaded afterjQuery as well.

任何其他依赖于 jQuery 的文件也必须在 jQuery之后加载。

    <!-- this one first! -->
 <script type="text/javascript" src="jquery-min.js" ></script>

 <script type="text/javascript" src="crosscut.js" ></script> 
 <script src="jquery-ui.min.js" type="text/javascript"></script>
 <script type="text/javascript" src="mod-min.js" ></script>

回答by ComputerSaysNo

are you using prototype js(or other libraries) along with jquery? note that you need to setup jquery for noconflict

你在使用原型 js(或其他库)和 jquery 吗?请注意,您需要为 noconflict 设置 jquery

see http://docs.jquery.com/Using_jQuery_with_Other_Libraries

http://docs.jquery.com/Using_jQuery_with_Other_Libraries

回答by Swati Pisal

if you are using jQuery.js load jQuery.js first and then other js Sequence also important.

如果您使用 jQuery.js,请先加载 jQuery.js,然后其他 js 序列也很重要。

    <script src="js/jQuery.js" type="text/javascript"></script>      
    <script src="js/jQuery.alert.js" type="text/javascript"></script>
    <script src="js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="js/CustomerSummary.js"></script>
    <link rel="stylesheet" href="css/style.css" type="text/css"></link>
    <link rel="stylesheet" href="css/style_new.css" type="text/css"></link>