2008-12-03 47 views
0

有谁知道为什么下面的代码只对FF有效?onclick on动画提交按钮只适用于FF(不IE或OP)

$(document).ready(function() { 
    $('#powerSearchSubmitButton').click(function() { 
     startLoad(); 
    }); 
}); 

function startLoad() { 
    $('.message').each(function(i) { 
     $(this).animate({ opacity: 0 }, 500);   
    }); 
}; 
+0

为什么被注释掉的代码和if语句呢?如果您提供重现此问题的最低代码会更好。 – 2008-12-03 11:28:27

+0

相当多的副本http://stackoverflow.com/questions/333911/jquery-animate-doesnt-work-as-expected-in-ie – leppie 2008-12-03 12:50:25

+0

这是javascript吗?美元符号有什么作用? – Albert 2008-12-03 22:51:52

回答

1

***更新****

例这里1个选项,这是保持信息的计数,仅在最后一条消息运行动画回调http://pastebin.me/4937b07714655


你为什么不从点击或event.preventDefault(返回false)和动画回调提交表单

$(document).ready(function() { 
    $('#powerSearchSubmitButton').click(function(ev) { 
     startLoad(); 
     ev.preventDefault(); 
    }); 
}); 

function startLoad() { 
    var $messages=$('.message'); 
    var count=$messages.length -1; 
    $messages.each(function(i) { 
     $(this).animate({ opacity: 0 }, 500, i == count ? submitForm:null);   
    }); 
}; 

function submitForm(){ 
    $('#yourForm').submit(); 
} 
1

尝试添加'return false;'到您的点击功能。我设置了演示on my site,它在IE6和Opera中正常工作。