First give a good Code : <textarea id="runcode58845"><Input type = "button" value = "valid for 5 seconds" onclick = "setTimeout (function (me) {me. disabled = true; return function () {me. disabled = false ;};}) (this), 5000); "></textarea>
[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]
The second option is also good.<Input type = "button" value = "valid for 5 seconds" onclick = "{<br/> This. disabled = true; <br/> var me = This; <br/> setTimeout (function () {me. disabled = false;}, 5000); <br/>} ">
[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]
The third method is simplified.<Input type = "button" value = "valid for 5 seconds" id = "me" onclick = "this. disabled = true; setTimeout ('me. disabled = false ', 5000); ">
[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]
the key lies in that this in the first setTimeout parameter is window, so a more practical variable
directly relying on this in setTimeout is not feasible because it points to window, it can be achieved through regionalization of nodes to be processed.
fengyan's method is to pass in the correct this reference before setTimeout executes the countdown, return a required packet with a correct node reference
As the execution function after the countdown of setTimeout. The parameter name is me or MES.