标签:show 获取 doc time() 练习 element ntb alert head
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="a">
</div>
<input type="button" onclick="clearTime()" value="清除" />
<script type="text/javascript">
window.onload=show();
// 进入页面开始加载
function show(){
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
var a = document.getElementById("a");
a.innerHTML=h+"时"+m+"分"+s+"秒";
}
var si = setInterval("show()",1000);
function clearTime(){
// 不能用clear(可能是关键字)
clearInterval(si);
}
</script>
<!--边看边思考规律,以便于记住-->
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="button" onclick="aa()" value="警告" />
<input type="button" onclick="bb()" value="确定" />
<input type="button" onclick="cc()" value="提示" />
<script type="text/javascript">
function aa(){
alert("警告框");
}
function bb(){
var flag = confirm("确定选择吗");
if (flag==true) {
alert("已确定");
}else {
alert("已取消");
}
}
function cc(){
var str = prompt("请输入","admin");
alert(str);
}
</script>
</body>
</html>
标签:show 获取 doc time() 练习 element ntb alert head
原文地址:https://www.cnblogs.com/ynzj123/p/13403045.html