how to delay the call to function JS - animated gif does not work in IE

advertisements

I'm struggling to get an animated gif to run in IE. Works in all other browsers, but in IE it just freezes. I've researched this and looks like a delay using setTimeout might work. Not too sure how I add this to the following function:

<script type="text/javascript">

    $(function(){
        $('#photo_form').on("submit", function () {
        $('#loading').show();

    });

    });

</script>

The gif is inside a div called 'loading' which is hidden. Would I add the timeout to onClick of the button or within the function itself?

Why does IE make things so difficult!?

Any help with solving this problem would be very helpful.


You mean something like this?

$(function() {

    $('#photo_form').on("submit", function () {

        setTimeout(function () {

              $('#loading').show();

        }, 100);

    });
});