Home > Web Front-end > JS Tutorial > Delayed display method for running time-consuming operations in JS_javascript skills

Delayed display method for running time-consuming operations in JS_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:15:54
Original
1272 people have browsed it

The code is as follows:

Copy code 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
Copy code The code is as follows:

document.getElementById("btnConnect" ).value = "Connecting";
setTimeout("Connect()", 1);

Then document.getElementById("btnConnect").value = "Connected"; Moved to Connect().
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template