javascript实现日期时间动态显示

.aspx代码例如以下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <script type="text/javascript">
         document.write("<span id=lblTime width='118px' height='11px' Font-Size='9pt' style='color:Red' ></span>") //输出显示日期的容器 
         //每1000毫秒(即1秒) 运行一次本段代码 
         setInterval("lblTime.innerText=new Date().toLocaleString()", 1000)  
</script>
    </div>
    </form>
</body>
</html>

效果例如以下:


原文地址:https://www.cnblogs.com/jzssuanfa/p/6775846.html