Change submit button to a loading image with jquery

后端 未结 9 1104
庸人自扰
庸人自扰 2021-02-06 11:12

On a lot of sites lately, I\'ve seen buttons being replaced with loading/thinking images after they are pressed, to prevent double clicks and make sure the user knows something

9条回答
  •  北海茫月
    2021-02-06 11:55

    Go the simplest way. Say your button is btnSubmit.

    
    
    

    Now using jquery, on click of the button:

    
    

    The submit button will be disabled, the animating image loading.gif will show up. And the page will postback. The benefit is that if validation fails you can again enable the submit button and hide the loading image. In such case, obviously you will show the error message.

提交回复
热议问题