动态显示
在html中从00到23点动态循环,是怎么写的?
------解决方案--------------------<script>
i = 0;
window.onload=f;
function f()
{
str = i<10?"0"+i:i;
document.getElementById("x").innerHTML=newDate()+str;
setTimeout('f()',1000);
i++;
}
</script>
<div id=x></div>
------解决方案--------------------<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" language="javascript">
i = 0;
window.onload = f;
function f() {
var str = i < 10 ? "0" + i : i;
document.getElementById("x").innerHTML = str;
setTimeout('f()', 1000);
i++;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="x">
</div>
</form>
</body>
</html>