简体   繁体   English

JQuery不起作用:未捕获的类型错误

[英]JQuery does not work: uncaught type error

I have placed the following JQuery script in my HTML site header just to test if it works : 我在我的HTML网站标题中放置了以下JQuery脚本, 以测试它是否有效

//in the header
<script src="modules/mod_djmenu/assets/js/catimage.js" type="text/javascript"></script>

//This is inside the script, it does load according to Chrome Developer Tools
$(document).ready(function(){
  $("#navbar").hide();
});

navbar does not hide and I get the error (in Chrome Developer Tools): 导航栏无法隐藏,我收到错误(在Chrome开发者工具中):

Uncaught TypeError: Object # has no method 'ready' 未捕获的TypeError:对象#没有方法'就绪'

Have I placed the script in the wrong place? 我把脚本放在了错误的地方吗? I use Joomla for my site btw. 我使用Joomla作为我的网站顺便说一句。

Site: europebathroom.com 网站: europebathroom.com

Thanks in advance! 提前致谢!

Include Jquery Library in head section 在头部包含Jquery库

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
<script src="modules/mod_djmenu/assets/js/catimage.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
 $("#navbar").hide();
});
</script>

Seems like you havent include jquery in your code. 好像你没有在你的代码中包含jquery。 Include the jquery, either by refering online or save it as local. 包括jquery,可以通过在线引用或将其保存为本地。

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="modules/mod_djmenu/assets/js/catimage.js" type="text/javascript"></script>

//This is inside the script, it does load according to Chrome Developer Tools
$(document).ready(function(){
  $("#navbar").hide();
});

Add this below script. 添加以下脚本。 before your script as you need to add jquery script before it. 在您的脚本之前,因为您需要在它之前添加jquery脚本。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM