Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery动画框_Javascript_Jquery_Position_Jquery Animate - Fatal编程技术网

Javascript jQuery动画框

Javascript jQuery动画框,javascript,jquery,position,jquery-animate,Javascript,Jquery,Position,Jquery Animate,我有一个框,我想动画时,点击一个链接。链接在框内-因此我无法隐藏框并使用简单的滑动切换功能。 我希望长方体滑动到底部位置:0px;,当再次点击时,它应该滑到底部:-71px 这是“我的盒子”HTML: <!-- LOGIN --> <div id="userlogin"> <div class="topbutton"><a href="#"><span>Log ind</span></a><

我有一个框,我想动画时,点击一个链接。链接在框内-因此我无法隐藏框并使用简单的滑动切换功能。 我希望长方体滑动到底部位置:0px;,当再次点击时,它应该滑到底部:-71px

这是“我的盒子”HTML:

    <!-- LOGIN -->
<div id="userlogin">
    <div class="topbutton"><a href="#"><span>Log ind</span></a></div>
    <form action="" method="POST" enctype="" onsubmit="document.getElementById('_form__submit').disabled = true;" target="" id="_form__form">
        <input type="hidden" name="module" value="Brugere" id="_form__module">
        <input type="hidden" name="page" value="login" id="_form__page">
        <input type="hidden" name="do" value="" id="_form__do">
        <input type="hidden" name="id" value="0" id="_form__id">
        <input type="hidden" name="lang_id" value="da" id="_form__lang_id">
        <input type="hidden" name="_form_" id="_form_" value="submit">
        <input type="hidden" name="when_done" value="" id="when_done">

        <div class="left">
            <p><span>Brugernavn</span><input type="text" name="username" value="" id="username" class="loginfield" /></p>
            <p><span>Adgangskode</span><input type="password" name="password" value="" id="password" class="loginfield" /></p>
        </div>
        <div class="right">
            <input type="submit" id="_form__submit" class="loginbutton" value="Log ind" /><br />
            <a href="/site/da/Brugere/forgot_password"><b>»</b> Glemt adgangskode?</a>
            <iframe width="0" height="0" src="" name="_form__iframe_save" frameborder="0" framespacing="0" scrolling="no"></iframe>
        </div>
        <div class="clear"></div>
    </form>
</div>
<!-- LOGIN -->
但这不起作用,有人能帮我吗?:)

试试看

    $("#userlogin .topbutton a").click(function () {
    $("#userlogin").stop(true).animate({bottom: '0'}, 500);
}, function () {
    $("#userlogin").stop(true).animate({bottom: '-71px'}, 500);
});
使用该方法


演示在

请详细解释什么不起作用?该方法不接受两个处理程序。你想在两者之间切换吗?OT:你应该带一个例子,只是好奇,但是为什么你必须先叫停止?你到底在停止什么?@cap俘,上一次点击的动画(如果还没有结束)啊!明白了……非常感谢!还有一件事,调用STOP是否会将对象返回到其原始(默认)状态(或位置)?或者它只是停止了上一个动画(无论它现在在哪里)?@PrisonerZERO:cleaning queue,它意味着它停止了,正如Gaby所说,上一个动画
    $("#userlogin .topbutton a").click(function () {
    $("#userlogin").stop(true).animate({bottom: '0'}, 500);
}, function () {
    $("#userlogin").stop(true).animate({bottom: '-71px'}, 500);
});
$("#userlogin .topbutton a").toggle(
function() {
    $("#userlogin").stop(true).animate({
        bottom: '0'
    }, 500);
}, function() {
    $("#userlogin").stop(true).animate({
        bottom: '-71px'
    }, 500);
});