Home >Web Front-end >JS Tutorial >js code to disable button for 5 seconds_form effects

js code to disable button for 5 seconds_form effects

WBOY
WBOYOriginal
2016-05-16 18:52:27893browse

First give a good code:


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute ]


The second type Not bad either

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute ]

The third one is more streamlined

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute ]

The key is that setTimeout is the first This in the first parameter is window, so a more practical variable
is needed. It is not feasible to directly rely on this in setTimeout, because it points to window, which can be achieved by globalizing the node that wants to be processed.
Fengyan’s method is to pass in the correct this reference before setTimeout executes the countdown, and return a required package with the correct node reference.
is the execution function after setTimeout counts down. It doesn't matter whether the parameter name is me or Mes.
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