案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<h3>演示如何访问 TIME 元素</h3>
6
7
<p>我在<time id="myTime" datetime="2014-02-14">情人节</time>有个约会。</p>
8
9
<p>点击按钮来获得以上 time 元素的日期。</p>
10
11
<p id="demo"></p>
12
13
<button onclick="myFunction()">试一下</button>
14
15
<p><b>注释:</b>time 元素不会在浏览器中呈现任何特殊的样式。</p>
16
<p><b>注释:</b>只有 Firefox 和 Opera 12 支持 dateTime 属性。</p>
17
18
<script>
19
function myFunction()
20
{
21
var x = document.getElementById("myTime").dateTime;
22
document.getElementById("demo").innerHTML = x;
23
}
24
</script>
25
26
</body>
27
</html>
28