Joomla 2.5 Jquery 无法调用 null 的方法 [英] Joomla 2.5 Jquery Cannot call method of null
本文介绍了Joomla 2.5 Jquery 无法调用 null 的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我正在将 Joomla 2.5 与 Jquery 一起使用,但在我的 chrome 控制台中出现了这个奇怪的错误:
Hi guys I am using Joomla 2.5 with Jquery and I got this strange error in my chrome console:
"Uncaught TypeError: Cannot call method 'slideUp' of null "
这里是 index.php 头部分:
here is index.php header section:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/jscript.js"></script>
<jdoc:include type="head" />
和 jscript.js 代码:
and jscript.js code:
$(document).ready(function(){
var slider = document.getElementById("login-form");
alert (slider);
$("#login-form").slideUp(100); <- error is on this line
});
我测试了它并且警报显示:[object HTMLFormElement],所以它意味着登录表单"确实存在.不明白为什么我得到
I tested it and alert showed : [object HTMLFormElement], so it meas "login-form" realy exists. can't figure out why am I getting
"Uncaught TypeError: Cannot call method 'slideUp' of null "
拜托,你能帮帮我吗!!!!!!
Please, can you help me!!!!!!
推荐答案
很可能您的 jquery 代码与 mootools 冲突.试试这个使用
Most probably your jquery code is conflicting with mootools. Try this using
jQuery.noConflict();
您的代码将如下所示-
var $j = jQuery.noConflict();
$j(document).ready(function(){
var slider = document.getElementById("login-form");
alert (slider);
$j("#login-form").slideUp(100);
});
这篇关于Joomla 2.5 Jquery 无法调用 null 的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文