到目前为止,当我单击一个事件时,我的应用程序正在运行,div 向左移动并出现下一个 div,到目前为止一切顺利。第一个转换有效,但当我想返回时它不起作用。
function animate_question(current_question, next_question, direction) {
if (direction == "left") {
$(current_question).animate({
left: "-=100",
opacity: "0"
}, {
"complete": function () {
$(current_question).remove();
$(next_question).delay(200).fadeIn();
}
});
} else if (direction == "right") {
$(current_question).animate({
left: "+=100",
opacity: "0"
}, {
"complete": function () {
$(current_question).remove();
$(next_question).delay(200).fadeIn();
}
});
}
}
编辑
上下文
$("#next2").click(function() {
var a = check_radio("Q1");
if(a) {
animate_question(".question1", ".question2", "left");
} else {
alertify.alert(message);
}
});
$("#back1").click(function() {
animate_question(".question2", ".question1", "right");
});
最佳答案
remove
实际上从 DOM 中删除元素。如果您再试一次,将不会有任何可以设置动画的元素。
关于javascript - 如何使用 jQuery 制作右/左隐藏和显示 div 的动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21562699/