Click here to Skip to main content
13,799,943 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
i have a javascript timer but i want the timer to start/continue when i type and after i dont type for about 20 seconds, to pause.

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


<script>
var c = 0;
function myCounter() {
  document.getElementById("demo").innerHTML = ++c;
}
</script>
	
Enter your name: <input type="text" id="fname" onkeyup="myFunction()">

	

	
	<script>
		var myTimer = setInterval(myCounter, 1000)
function myFunction() {
	  setTimeout(function(){clearInterval(myTimer)}, 5000);
}
    </script>
	
 	<script>
function myFunction() {
	  setTimeout(function(){myTimer}, 1000);
}
    </script>


What I have tried:

please help. i dont know why it wont work.
Posted 6-Dec-18 15:47pm
Updated 7-Dec-18 8:47am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

bump
please
answer
my
question
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.181214.1 | Last Updated 7 Dec 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100