how to make a stopwatch using js
JavaScript
//create a function to stop the time function stopTime( ) {
/* check if seconds, minutes and hours are not equal to 0 */
<!DOCTYPE html>
<html lang="en">
<head>
<title> JavaScript Stop Watch </title>
<style text="text/css">
#stopWatch { width: 280px;
height: auto;
text-align: center;
display: block;
padding: 5px;
margin: 0 auto; }
#timer, #fulltime { width: auto;
height: auto;
padding: 10px;
font-weight: bold;
font-family: tahoma;
display: block;
border: 1px solid #eee;
text-align: center;
box-shadow: 0 0 5px #ccc;
background: #fbfbf0;
color: darkblue;
border-bottom:4px solid darkgrey; }
button { cursor: pointer; font-weight: 700; }
#fulltime { display:none; font-size:16px; font-weight:bold; }
</style>
<script type="text/javascript">
</script>
</head>
<body>
<section id="stopWatch">
<p id="timer"> Time : 00:00:00 </p>
<button id="start"> Start </button>
<button id="stop"> Stop </button>
<p id="fulltime"> </p>
</section>
<script>
if ( seconds !== 0 || minutes !== 0 || hours !== 0 ) {
/* display the full time before reseting the stop watch */
var fulltime = document .getElementById( "fulltime" );
//display the full time fulltime.style.display = "block";
var time = gethours + mins + secs;
fulltime.innerHTML = 'Fulltime: ' + time;
// reset the stop watch seconds = 0; minutes = 0; hours = 0; secs = '0' + seconds; mins = '0' + minutes + ': '; gethours = '0' + hours + ': '; /* display the stopwatch after it's been stopped */ var x = document.getElementById ("timer"); var stopTime = gethours + mins + secs; x.innerHTML = stopTime; /* display all stop watch control buttons */ var showStart = document.getElementById ('start'); showStart.style.display = "inline-block"; var showStop = document.getElementById ("stop"); showStop.style.display = "inline-block"; /* clear the stop watch using the setTimeout( ) return value 'clearTime' as ID */ clearTimeout( clearTime ); } // if () } // stopTime() /* you need to call the stopTime( ) function to terminate the stop watch */ window.addEventListener( 'load', function ( ) { var stop = document.getElementById ("stop"); stop.addEventListener( 'click', stopTime ); }); // stopwatch.js end
</script>
</body>
</html>
Also in JavaScript:
- Title
- Discord embeds
- Category
- JavaScript
- Title
- align left text in reactstrap
- Category
- JavaScript
- Title
- filter keys from object using ramda
- Category
- JavaScript
- Title
- display none in jquery
- Category
- JavaScript
- Title
- exponential javascript
- Category
- JavaScript
- Title
- Is there an “exists” function for jQuery
- Category
- JavaScript
- Title
- fs writefile node
- Category
- JavaScript
- Title
- how to check for duplicate syntax in javascript
- Category
- JavaScript
- Title
- inheritance in javascript
- Category
- JavaScript
- Title
- express js sample project
- Category
- JavaScript
- Title
- express get query params from url
- Category
- JavaScript
- Title
- adonis js sort by
- Category
- JavaScript
- Title
- how to open a new html page on button click in javascript
- Category
- JavaScript
- Title
- email regex javscript
- Category
- JavaScript
- Title
- how to set random dice image with js
- Category
- JavaScript
- Title
- array in javascript
- Category
- JavaScript
- Title
- how to implement cland format into js file
- Category
- JavaScript
- Title
- import npm module node.js
- Category
- JavaScript
- Title
- convert negative number to positive in javascript
- Category
- JavaScript
- Title
- delete session javascript
- Category
- JavaScript
- Title
- express() vs express.router()
- Category
- JavaScript
- Title
- javascript break out of loop
- Category
- JavaScript
- Title
- disregard empty field in array
- Category
- JavaScript
- Title
- how to add javascript to html
- Category
- JavaScript
- Title
- how to create a server in node js
- Category
- JavaScript
- Title
- howt to convert 2020-02-01T08:54:07.284Z to date in javascript react
- Category
- JavaScript
- Title
- compare two arrays javascript
- Category
- JavaScript
- Title
- google sign in in firebase react
- Category
- JavaScript
- Title
- javascript array flatten
- Category
- JavaScript
- Title
- for loop js example
- Category
- JavaScript
- Title
- install node js lts ubuntu 18.04
- Category
- JavaScript
- Title
- how to close another browser tab with javascript
- Category
- JavaScript
- Title
- javascript array map stack
- Category
- JavaScript
- Title
- how to loop over dom objects javascript
- Category
- JavaScript
- Title
- ignore node modules
- Category
- JavaScript
- Title
- check if a key exists in an object javascript
- Category
- JavaScript
- Title
- check value exist in array javascript
- Category
- JavaScript
- Title
- event target javascript
- Category
- JavaScript
- Title
- find index of object in array javascript
- Category
- JavaScript
- Title
- adjust() js
- Category
- JavaScript
- Title
- how to log to the console javascript
- Category
- JavaScript
- Title
- javascript array to comma separated list
- Category
- JavaScript
- Title
- get id of clicked element javascript
- Category
- JavaScript
- Title
- how To fetch the index of dropdown using jquery
- Category
- JavaScript
- Title
- how to check how many strings are in a sentence javascript
- Category
- JavaScript
- Title
- How to uninstall npm modules in node js?
- Category
- JavaScript
- Title
- counter exapmle in vue js
- Category
- JavaScript
- Title
- electron jquery
- Category
- JavaScript
- Title
- collapse in angular 4
- Category
- JavaScript
- Title
- get text in select jquery
- Category
- JavaScript
- Title
- ajax with django
- Category
- JavaScript
- Title
- discord.js send message to channel
- Category
- JavaScript
- Title
- how to use a js class in react
- Category
- JavaScript
- Title
- javascript check if text is overflowing
- Category
- JavaScript
- Title
- javascript add commas to number
- Category
- JavaScript
- Title
- angular run behind proxy
- Category
- JavaScript
- Title
- child process spawn python node js
- Category
- JavaScript
- Title
- how to align text inside react component
- Category
- JavaScript
- Title
- find method javascript
- Category
- JavaScript
- Title
- get all keys in json object
- Category
- JavaScript
- Title
- export aab bundle react native android
- Category
- JavaScript
- Title
- javascript check if browser is ie
- Category
- JavaScript
- Title
- Find parent and child from array javascript
- Category
- JavaScript
- Title
- bootstrap modal remove gray background
- Category
- JavaScript
- Title
- how to ask input in javascript
- Category
- JavaScript
- Title
- Cannot find module '.json'
- Category
- JavaScript
- Title
- how to get today date in javascript
- Category
- JavaScript
- Title
- display none js
- Category
- JavaScript
- Title
- get parent element using jquery
- Category
- JavaScript
- Title
- get current time epoch javascript
- Category
- JavaScript
- Title
- how to send enter event to input field jquery
- Category
- JavaScript
- Title
- event listener javascript
- Category
- JavaScript
- Title
- export to logs to elasticsearch node from fluend container k8s
- Category
- JavaScript
- Title
- How do I get Month and Date of JavaScript in 2 digit format
- Category
- JavaScript
- Title
- installing vue router & implementation
- Category
- JavaScript
- Title
- discord js get badge user
- Category
- JavaScript
- Title
- create react native app npx
- Category
- JavaScript
- Title
- Find channel discord js
- Category
- JavaScript
- Title
- how to inject service in component angular 6
- Category
- JavaScript
- Title
- array of objects javascript
- Category
- JavaScript
- Title
- Better Array check with Array.isArray Because arrays are not true array in JavaScript, there is no simple typeof check. No problem! Use the method Array.isArray to check…
- Category
- JavaScript
- Title
- installing bootstrap in angular 9
- Category
- JavaScript
- Title
- Bots latency discord js
- Category
- JavaScript
- Title
- anguler test submit form
- Category
- JavaScript
- Title
- how to auto refresh page in javascript
- Category
- JavaScript
- Title
- angular rebuild
- Category
- JavaScript
- Title
- html table to excel javascript
- Category
- JavaScript
- Title
- client timezone offset in JavaScript
- Category
- JavaScript
- Title
- how to write a program that tests whether it's before noon and alert “Its AM” else “its PM” in javascript
- Category
- JavaScript
- Title
- import jquery
- Category
- JavaScript
- Title
- javascript array split chunk
- Category
- JavaScript
- Title
- can we import jquery library from developer tools
- Category
- JavaScript
- Title
- array definition js
- Category
- JavaScript
- Title
- how to change package name in react native
- Category
- JavaScript
- Title
- how to make all lowercase in js
- Category
- JavaScript
- Title
- hello
- Category
- JavaScript
- Title
- aws amplify get JWT TOKEN
- Category
- JavaScript
- Title
- casl react
- Category
- JavaScript
- Title
- add class javascript
- Category
- JavaScript
- Title
- clear input field value javascript
- Category
- JavaScript