<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var c = 3;
var t;
function timedCount() {
document.getElementById('txt').value = c
c = c - 1
if (c == 0) {
alert("asdf");
} else {
t = setTimeout("timedCount()", 1000);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="button" value="Start count!" onclick="timedCount()" />
<input type="text" id="txt" />
</form>
</body>
</html>
简单的JS实现按钮触发倒计时功能
最新推荐文章于 2024-10-06 12:17:25 发布