javascript making a stopwatch code example
Example 1: how to make a stopwatch using js
<!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 ) {
var fulltime = document .getElementById( "fulltime" );
var time = gethours + mins + secs;
fulltime.innerHTML = 'Fulltime: ' + time;
</script>
</body>
</html>
Example 2: stopwatch with javascript
<h1>
<span id="hour">00</span> :
<span id="min">00</span> :
<span id="sec">00</span> :
<span id="milisec">00</span>
</h1>
<button onclick="startStop()" id="start">Start</button>
<button onclick="reset()">Reset</button>