jQuery toggle both “slide” and “fade” animations at the same time

[亡魂溺海] 提交于 2021-02-07 13:54:11

问题


jQuery has a slideToggle, and a fadeToggle, but they don't play well together (see fiddle here):

$('div').on('click', function () {
    $('span')
        .slideToggle({duration: 'slow', queue: false})
        .fadeToggle({duration: 'slow', queue: false});
});

How can I have slide and fade toggle at the same time?


回答1:


Use .animate() as follows:

$('span').animate({
  height: "toggle",
  opacity: "toggle"
});


来源:https://stackoverflow.com/questions/14789388/jquery-toggle-both-slide-and-fade-animations-at-the-same-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!