Get Time Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Time

Introduction

The Time object represents an HTML <time> element.

You can access a <time> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<time id="myTime" datetime="2014-02-14">Valentines day</time>

<button onclick="myFunction()">get the HTML content of the time element</button>

<p id="demo"></p>

<script>
function myFunction() {//from   w  w w. java  2s  .  c  om
    var x = document.getElementById("myTime").innerHTML;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials