First, give a good code:
<Input type = "button" value = "valid for 5 seconds" onclick = "setTimeout (function (me) {me. disabled = true; return function () {me. disabled = false ;};}) (this), 5000); ">
[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 = "5 seconds after expiration" onclick = "{this. disabled = true; var me = this; setTimeout (function () {me. disabled = false;}, 5000);} ">
[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 is that this in the first setTimeout parameter is window, so a more practical variable is required.
Directly relying on this in setTimeout is not feasible, because it points to the window, which can be implemented through the vertices to be processed.
Fengyan's method is to pass in the correct this reference before setTimeout executes the countdown, and return a required packet with the correct node reference
It is the execution function after the countdown of setTimeout. The parameter name is me or Mes.