用一个按钮控制一个DIV里德倒计时时,按一下错,确实倒计时了,为什么再按一下倒计时的速度会变快 10
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN"><html><head><title>按钮倒计时</tit...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>按钮倒计时</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="ProgId" content="VisualStudio.HTML">
<meta name="Originator" content="Microsoft Visual Studio .NET 7.1">
<script language="javascript">
function TimeLast()
{
document.all.Text1.value = parseInt(document.all.Text1.value) -1;
if (parseInt(document.all.Text1.value) ==0)
{
document.all.Text1.value="时间到了";
}
else
{
setTimeout("TimeLast()",1000);
}
}
</script>
</head>
<body>
<form>
<INPUT id="Text1" type="text" name="Text1" value="10">
<INPUT id="Button1" type="button" value="Button" name="Button1" onclick="TimeLast();">
</form>
</body>
</html>
不要按钮disabled 我要知道这是什么原因啊,恳请各位高手解释下啊 展开
<html>
<head>
<title>按钮倒计时</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="ProgId" content="VisualStudio.HTML">
<meta name="Originator" content="Microsoft Visual Studio .NET 7.1">
<script language="javascript">
function TimeLast()
{
document.all.Text1.value = parseInt(document.all.Text1.value) -1;
if (parseInt(document.all.Text1.value) ==0)
{
document.all.Text1.value="时间到了";
}
else
{
setTimeout("TimeLast()",1000);
}
}
</script>
</head>
<body>
<form>
<INPUT id="Text1" type="text" name="Text1" value="10">
<INPUT id="Button1" type="button" value="Button" name="Button1" onclick="TimeLast();">
</form>
</body>
</html>
不要按钮disabled 我要知道这是什么原因啊,恳请各位高手解释下啊 展开
2个回答
展开全部
楼上已经讲出了问题所在 我帮你解决 在你的代码上改动
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>按钮倒计时</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="ProgId" content="VisualStudio.HTML">
<meta name="Originator" content="Microsoft Visual Studio .NET 7.1">
<script language="javascript">
var mytime=new Array();
function TimeLast(t)
{
if (t=="1")
{
clearTimeout(mytime[document.all.Text1.value]);
document.all.Text1.value=11;
}
document.all.Text1.value = parseInt(document.all.Text1.value) -1;
if (parseInt(document.all.Text1.value) ==0)
{
document.all.Text1.value="时间到了";
}
else
{
mytime[document.all.Text1.value]=setTimeout("TimeLast(0)",1000);
}
}
</script>
</head>
<body>
<form>
<INPUT id="Text1" type="text" name="Text1" value="10">
<INPUT id="Button1" type="button" value="Button" name="Button1" onclick="TimeLast(1);">
</form>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>按钮倒计时</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="ProgId" content="VisualStudio.HTML">
<meta name="Originator" content="Microsoft Visual Studio .NET 7.1">
<script language="javascript">
var mytime=new Array();
function TimeLast(t)
{
if (t=="1")
{
clearTimeout(mytime[document.all.Text1.value]);
document.all.Text1.value=11;
}
document.all.Text1.value = parseInt(document.all.Text1.value) -1;
if (parseInt(document.all.Text1.value) ==0)
{
document.all.Text1.value="时间到了";
}
else
{
mytime[document.all.Text1.value]=setTimeout("TimeLast(0)",1000);
}
}
</script>
</head>
<body>
<form>
<INPUT id="Text1" type="text" name="Text1" value="10">
<INPUT id="Button1" type="button" value="Button" name="Button1" onclick="TimeLast(1);">
</form>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询