Home > Web Front-end > JS Tutorial > Javascript implements date and time dynamic display sample code_javascript skills

Javascript implements date and time dynamic display sample code_javascript skills

WBOY
Release: 2016-05-16 15:39:59
Original
1321 people have browsed it

Without further ado, let’s get straight to the code:

<!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>
Copy after login

There are also operation renderings:

Isn’t it very simple? This is the most basic method of dynamically displaying time changes on a page. You can innovate on this basis and add some styles. I hope this article will help you master javascript to achieve dynamic display of date and time. .

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