Joomla 2.5 Jquery无法调用null的方法 [英] Joomla 2.5 Jquery Cannot call method of null

查看:110
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆