js时间控件

JavaScript09

js时间控件,第1张

My97DatePicker,将dateFmt设置为"HH:mm:ss"

<input type="text" onclick="WdatePicker({dateFmt:'HH:mm:ss'})" />

效果:

需要准备的材料分别有:电脑、html编辑器、浏览器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<script>标签,输入js代码:

var a = new Date()document.body.innerHTML

= '时:' + a.getHours() + '<br/>分:' + a.getMinutes() + '<br/>秒:' + a.getSeconds()

3、浏览器运行index.html页面,此时当前时间的时分秒都被js获取并打印了出来。

<html>

<head>

<title>setTimeout()</title>

<style type="text/css">

input

{

font-size:30px

border-style:none

background-color:#ff8b3b

}

</style>

</head>

<body onLoad="disptime()">

<form name="myform" >

<table width="100%" border="0" align=center>

<tr>

<td width="37%"> </td>

<td width="41%"><h2>当前时间:<input name="myclock" type="text" value=" " size="10"></h2></td>

<td width="22%"> </td>

</tr>

</table>

</form>

</body>

</html>

<script type="text/javascript">

function disptime()

{

var time=new Date()

var hour=time.getHours()

var minute=time.getMinutes()

var second=time.getSeconds()

document.myform.myclock.value=hour+":"+minute+":"+second+" "

var myTime=setTimeout("disptime()",1000)

}

</script>

我刚刚写的