Jquery 停止动画后更改css属性
我想在动画完成后更改文本颜色 我试试这个: 但是不起作用!:/Jquery 停止动画后更改css属性,jquery,css,animation,if-statement,slide,Jquery,Css,Animation,If Statement,Slide,我想在动画完成后更改文本颜色 我试试这个: 但是不起作用!:/ var menuState="closed"; $("#MENU").click(function() { if (menuState=="closed") { $("#SOUSMENU").animate({height: "300px"}, 1000); menuState="open"; } else if (menuState=="open"){ $("#SOUSMENU").animate({height: "0px"
var menuState="closed";
$("#MENU").click(function() {
if (menuState=="closed") {
$("#SOUSMENU").animate({height: "300px"}, 1000);
menuState="open";
} else if (menuState=="open"){
$("#SOUSMENU").animate({height: "0px"}, 1000);
menuState="closed";}});
$("#MENU").click(function() {
if (menuState=="open") {
$("h1").css('color','red');
} else if (menuState=="closed"){
$("h1").css('color','black');
menuState="closed"; }
});
谢谢你宝贵的帮助 使用
.animate
var menuState="closed";
$("#MENU").click(function() {
if (menuState=="closed") {
$("#SOUSMENU").animate({height: "300px"}, 1000, function() {
$("h1").css('color','red');
});
menuState="open";
} else if (menuState=="open"){
$("#SOUSMENU").animate({height: "0px"}, 1000, function() {
$("h1").css('color','black');
});
menuState="closed";
}
});
演示:使用
的回调。制作动画
var menuState="closed";
$("#MENU").click(function() {
if (menuState=="closed") {
$("#SOUSMENU").animate({height: "300px"}, 1000, function() {
$("h1").css('color','red');
});
menuState="open";
} else if (menuState=="open"){
$("#SOUSMENU").animate({height: "0px"}, 1000, function() {
$("h1").css('color','black');
});
menuState="closed";
}
});
演示:@user2657939也有一点不同的小提琴@user2657939也有一点不同的小提琴