Home > Web Front-end > JS Tutorial > Method for JS control button to be available after 10 seconds_javascript skills

Method for JS control button to be available after 10 seconds_javascript skills

WBOY
Release: 2016-05-16 15:24:16
Original
1701 people have browsed it

The example in this article describes the method of using JS to control the button after 10 seconds. Share it with everyone for your reference, the details are as follows:

<script language="javascript">
function start()
{
  document.getElementById("Button1").disabled = true;
  document.getElementById("Button1").value = 10;
  window.setTimeout("tick()",1000);
}
function tick()
{
  var time = new Number(document.getElementById("Button1").value);
  if(time>0)
  {
    document.getElementById("Button1").value = time-1;
    window.setTimeout("tick()",1000);
  }
  else
  {
    document.getElementById("Button1").disabled = false;
    document.getElementById("Button1").value = "保存";
  }
}
</script>
<form>
<INPUT TYPE="button" NAME="Button1" id="Button1">
</form>
<script language=javascript>
 start();
</script>

Copy after login

I hope this article will be helpful to everyone in JavaScript programming.

Related labels:
js
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