如果我理解正确,您可能需要替换它:
$('#myForm').ajaxForm(function() {
document.getElementById('formFill').style.visibility = 'hidden';
document.getElementById('joinDiv').style.width = '842px';
$("#joinText").html( 'Thank you for signing up!');
});
有了这个:
$('#myForm').ajaxForm(function() {
document.getElementById('formFill').style.visibility = 'hidden';
$("#joinText").html( 'Thank you for signing up!');
$('#joinDiv').animate({width: '842px'}, 1000, 'swing');
});
第一个参数animate
是一个散列,描述了您想要结束动画的“结束状态”。看起来您的 joinDiv 是 649px 或其他大小,因此该animate
调用将在 1 秒内将其从 649 增加到 842(1000 毫秒,第二个参数)。对于这种类型的东西来说,这是一种缓慢的过渡,但是您可以通过将 1000 减少到某个较低的数字来轻松地对其进行调整。第三个参数是缓动函数。有一个可选的第四个参数,它在动画完成后接受一个回调函数来做某事。
The first parameter can have a bunch more stuff in it. You could have, for example, {width: '842px', height: '200px', opacity: '0.0'}
and it would grow in height and width, while fading from its starting value of 80% opacity to completely transparent, all smoothly at the same time.