[英]Toggle isn't executed
I have a click function, which is being executed, because the fadeToggles work. 我有一个正在执行的click函数,因为fadeToggles起作用。 But the div#overlay-sources I'm trying to animate, isn't animated.
但是我要制作动画的div#overlay-sources没有动画。 I have set it a height of 0px to start with, and then it should be animated to 480px.
我将其高度设置为0px,然后将其设置为480px。 The animation in itself works, I have tested it outside of the toggle function.
动画本身可以工作,我已经在切换功能之外对其进行了测试。 But somehow the toggle function isn't executed.
但是不知道切换功能没有执行。
$("#button-up").click(function(){
$("#overlay-sources").toggle(
function()
{
$(this).animate({height: "480px"}, 500);
},
function()
{
$(this).animate({height: "0px"}, 500);
});
$("#overlay-sources").fadeToggle('fast');
$("#blackout").fadeToggle('fast');
});
If you're not opposed to jQueryUI, or have already included it, that entire top part: 如果您不反对jQueryUI或已经将其包括在内,那么整个顶部将是:
$("#overlay-sources").toggle(
function()
{
$(this).animate({height: "480px"}, 500);
},
function()
{
$(this).animate({height: "0px"}, 500);
});
Becomes: 成为:
$("#overlay-sources").slideToggle(500);
But don't CSS the height to 0, simply display:none
, and the function will handle the height animation. 但是不要将CSS的高度设为0,只需
display:none
,该函数将处理高度动画。
EDIT 编辑
I'm sorry, I was mistaken. 对不起,我错了。 It looks like
slideToggle
is a part of the jQuery core library, and does not require jQuery UI 看起来
slideToggle
是jQuery核心库的一部分,并且不需要jQuery UI
This is what I needed. 这就是我所需要的。
$("#button-up").toggle(
function()
{
$("#overlay-sources").animate({top: "141px"}, 500);
$("#blackout").fadeToggle('fast');
},
function()
{
$("#overlay-sources").animate({top: "690px"}, 500);
$("#blackout").fadeToggle('fast');
}
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.