Animation for onclick on submit button only works in FF (not IE and OP)

Does anyone know why the following code only works in FF?

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

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

      

0


source to share


2 answers


*** Update ****

An example is here http://pastebin.me/4937b07714655 of 1 option, which should contain the number of messages and trigger the animation callback only on the last message.




why don't you return false from click or .preventDefault () event and in the animation callback submit the form

$(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


source


Try adding "return false"; to your click function. I have installed the demo on my site and it works great in IE6 and Opera.



+1


source







All Articles