Joomla 2.5 Jquery无法调用null方法

Ira*_*kli 0 null jquery joomla element slideup

嗨伙计们我正在使用Joomla 2.5和Jquery,我在Chrome控制台中遇到了这个奇怪的错误:

"Uncaught TypeError: Cannot call method 'slideUp' of null "
Run Code Online (Sandbox Code Playgroud)

这里是index.php标题部分:

    <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" />
Run Code Online (Sandbox Code Playgroud)

和jscript.js代码:

$(document).ready(function(){

    var slider = document.getElementById("login-form");

    alert (slider);

    $("#login-form").slideUp(100); <- error is on this line

});
Run Code Online (Sandbox Code Playgroud)

我测试了它并且警告显示:[object HTMLFormElement],所以它的测试"登录表单"真的存在.无法弄清楚我为什么会这样

"Uncaught TypeError: Cannot call method 'slideUp' of null "
Run Code Online (Sandbox Code Playgroud)

拜托,能帮帮我!!!!!!

Irf*_*fan 6

很可能你的jquery代码与mootools冲突.试试这个

jQuery.noConflict();

您的代码如下所示 -

var $j = jQuery.noConflict();
$j(document).ready(function(){

    var slider = document.getElementById("login-form");

    alert (slider);

    $j("#login-form").slideUp(100);

});
Run Code Online (Sandbox Code Playgroud)