The code is as follows:
document.getElementById("btnConnect"). value = "Connecting";
Connect(); // Time-consuming operation
document.getElementById("btnConnect").value = "Connected";
Execute I found that the button did not change to the "Connecting" state, but waited for Connect(); to finish executing before quickly changing it to "Connecting"
I was very depressed all afternoon. Later, my classmates helped and provided One method, plus setTimeout, achieves the desired effect.
The code is as follows
document.getElementById("btnConnect" ).value = "Connecting";
setTimeout("Connect()", 1);
Then document.getElementById("btnConnect").value = "Connected"; Moved to Connect().
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn