jQuery反向点击动画 [英] jQuery reverse animation on click

查看:80
本文介绍了jQuery反向点击动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

浏览了一些现有的问题,他们帮助我取得了进展,但仍然无法解决问题.

Looked through a few of the existing questions and they helped me get this far, but still cannot get it working.

$('#languageSelctor').click(function()
{
    $('#languageList').toggle(function()
    {
        $(this).animate({"top": "20px"},500);
    },  function() 
    {
        $(this).animate({"top": "-100px"},500);
    });
});

设法将上面的代码放在一起,但是现在它不起作用了.因此,当有人单击languageSelctor时,如果再次单击languageList,则languageList需要出现然后消失.

Managed to put together the above code, but now it just does not work. So when someone clicks on languageSelctor, languageList needs to appear and then disappear if they click on languageList again.

推荐答案

$('#languageSelctor').click(function() {
    var $language = $('#languageList'),
        top = $language.css('top') === '-100px' ? '20px' : '-100px';
    $language.stop().animate({top: top}, 500);  
});

这篇关于jQuery反向点击动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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