使用jquery表单插件动画消息

5 validation jquery animation

我在使用jquery Form Plugin时遇到问题.我有一个表单,我希望在用户提交错误信息时为错误/成功设置动画,或者在输入正确信息时向用户提供成功消息.但是我的问题是双重的.显示在同一页面上的消息只能在firefox中使用我当前使用的jquery.什么会导致这个?

我想在显示时将不同的消息滑入视图,但是现在它们只是弹出视图.如何使其动画或滑入视图?有问题的页面在这里

$(document).ready(function() { 
var options = { 
target:        '#alert',
}; 
$('#myForm').ajaxForm(options); 
}); 

$.fn.clearForm = function() {
  return this.each(function() {
    var type = this.type, tag = this.tagName.toLowerCase();
    if (tag == 'form')
      return $(':input',this).clearForm();
    if (type == 'text' || type == 'password' || tag == 'textarea')
      this.value = '';
    else if (type == 'checkbox' || type == 'radio')
      this.checked = false;
    else if (tag == 'select')
      this.selectedIndex = -1;
  });
};
/*this is my addition to getting the slide into view, but does not work */
$('#alert').onsubmit(function() {
    // This will be called before the form is submitted
    $('.message').show().animate("slow");
});


/*$(function() {
        $('.message').('slow').show('slow');
        $('.message').('slow').show('slow').animate({opacit:1.0}, 4000).hide('slow');
    $('input').clearForm()
}); */ 
Run Code Online (Sandbox Code Playgroud)

kar*_*m79 4

尝试这样做,普通的 show()/hide() 方法也可以做动画:

$('.message').show("slow");
Run Code Online (Sandbox Code Playgroud)

参见 jQueryshow( speed, [callback] )

医生说:

使用优雅的动画显示所有匹配的元素,并在完成后触发可选的回调。

另外,您错误地使用了 animate() 。为了让它工作,至少你需要将一些 CSS 属性作为一组选项传递给它。请参阅文档:

http://docs.jquery.com/Effects/animate

编辑:这就是我的意思是你使用我的建议:

$('#alert').onsubmit(function() {
    // This will be called before the form is submitted
    $('.message').show("slow");
});
Run Code Online (Sandbox Code Playgroud)