Show loading gif after clicking form submit using jQuery

前端 未结 4 1488
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 17:25

I\'m trying to simply show a loading gif once the form is submitted. My code is not working correctly for the loading gif to show. You\'ll see my image for the gif is set to

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 18:19

    The show() method only affects the display CSS setting. If you want to set the visibility you need to do it directly. Also, the .load_button element is a button and does not raise a submit event. You would need to change your selector to the form for that to work:

    $('#login_form').submit(function() {
        $('#gif').css('visibility', 'visible');
    });
    

    Also note that return true; is redundant in your logic, so it can be removed.

提交回复
热议问题