Window setTimeout() Method - Display a timed text - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setTimeout

Description

Window setTimeout() Method - Display a timed text

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="timedText()">Display timed text</button>
<input type="text" id="txt">

<script>
function timedText() {//from   ww w .j a v a  2  s . c o  m
    var x = document.getElementById("txt");
    setTimeout(function(){ x.value="2 seconds" }, 2000);
    setTimeout(function(){ x.value="4 seconds" }, 4000);
    setTimeout(function(){ x.value="6 seconds" }, 6000);
}
</script>

</body>
</html>

Related Tutorials