有人知道为什么以下代码只在FF中有效吗?
$(document).ready(function() {
$('#powerSearchSubmitButton').click(function() {
startLoad();
});
});
function startLoad() {
$('.message').each(function(i) {
$(this).animate({ opacity: 0 }, 500);
});
};
答案 0 :(得分:1)
尝试添加'return false;'到你的点击功能。我设置了一个演示on my site,它在IE6和Opera中运行良好。
答案 1 :(得分:1)
*** ****更新
这里示例http://pastebin.me/4937b07714655的1个选项,用于保留消息的计数并仅在最后一条消息上运行动画回调。
为什么不从click或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();
}