Today, when all the checkbox selections, reverse selection, and small JavaScript scripts are canceled, the page is refreshed instantly after clicking, and all the selected checkboxes are canceled. After debugging for half a day, I found out that the reason why the <button> label rarely writes a type attribute is depressing. I hope I will make this special 2 mistake in the future. I hereby record it.
Copy codeThe Code is as follows:
<! -- The following is the incorrect syntax -->
<Button name = "checkAll" value = "select all" class = "checkButton" onClick = "checkAll (form_favor, status)"> select all </button>
Copy codeThe Code is as follows:
<! -- Correct writing -->
<Button name = "checkAll" type = "button" value = "select all" class = "checkButton" onClick = "checkAll (form_favor, status)"> select all </button>
After reading the w3c description, I instantly understood that, without writing the type attribute, the browser processed it as a submit by default, while the script for processing the form was still empty, so there is a "refresh" phenomenon!