Home >Web Front-end >JS Tutorial >Three ways to make the button gray and unavailable after clicking the submit button_javascript skills
The first method: directly add
to the buttonWhen you click submit, the submit button turns gray and becomes unavailable, which can effectively prevent repeated submissions. This code implements such a function. As can be seen from the code, we only need to add this sentence to the submit button: onclick="javascript:{this.disabled=true;document.form1.submit();}", which means that when the button is clicked, the button The unavailable attribute is set to true, so that the button becomes gray