Initializing...
Liveweave
expand_more
home
Home
data_object
CSS Explorer
arrow_outward
Palette
Color Explorer
arrow_outward
Polyline
Graphics Editor
arrow_outward
outbox_alt
Generative AI
arrow_outward
build
Tools
expand_more
restart_alt
Load base template
post_add
Generate Lorem ipsum...
code
Format HTML
code_blocks
Format CSS
data_object
Format JavaScript
library_add
Library
expand_more
A
Algolia JS
Animate CSS
Apex Charts JS
B
Bulma CSS
Bootstrap
C
Chart JS
Chartist
Create JS
D
D3
Dojo
F
Foundation
Fullpage JS
G
Granim JS
Google Charts
H
Halfmoon
J
jQuery
M
Materialize
Moment JS
Masonry JS
Milligram CSS
P
Pure CSS
Primer CSS
Popper JS
Pattern CSS
Picnic CSS
R
React JS
Raphael JS
Raisin CSS
S
Semantic UI
Skeleton CSS
Spectre CSS
Tachyons CSS
T
Tailwind
Three JS
U
UI Kit
Vis JS
W
Water CSS
download
Download
expand_more
developer_mode
Download as HTML
folder_zip
Download as .ZIP
cloud_upload
Save
account_circle
Login
settings
Settings
expand_more
14
px
Live mode
Night mode
Line number
Mini map
Word wrap
sync_alt
Reset Settings
smart_display
Run
<!DOCTYPE html> <html> <head> <title>HTML5, CSS3 and JavaScript demo</title> </head> <body> <!-- Start your code here --> <section id="main"> <button id="start">Start</button> <button id="reset">Reset</button> <div id="display">0:00.0</div> <pre id="log"></pre> </section> <!-- End your code here --> </body> </html>
button { width: 100px; background-color: #FF4500; } #display { background-color: #000000; color: #ADFF2F; padding: 3px; width: 198px; text-align: right; font-family: monospace; font-weight: bold; } #log { width: 198px; border: 1px solid #777; padding: 2px; background-color: #c0c0c0; }
/* Write JavaScript here */ var tcontrol = false; var tseconds = 0; function $(id) { return document.getElementById(id); } function update_display() { var min = Math.floor(tseconds / 600); var sec = (tseconds % 600)/10; if (sec < 10) sec = "0" + sec; if ((sec - Math.floor(sec)) === 0) sec += ".0"; var hou = ""; if (min >= 60) { hou = Math.floor(min / 60) + ":"; min = min % 60; if (min < 10) hou += "0"; } $("display").innerHTML = hou + min + ":" + sec; } function start_stop() { var c; if (tcontrol === false) { tcontrol = window.setInterval(function() { tseconds++; update_display(); }, 100); c = "Stop"; } else { window.clearInterval(tcontrol); tcontrol = false; c = "Start"; $("log").innerHTML += $("display").innerHTML + "\n"; } $("start").innerHTML = c; } $("start").addEventListener("click", start_stop, false); $("reset").addEventListener("click", function() { tseconds = 0; window.clearInterval(tcontrol); tcontrol = false; $("log").innerHTML = ""; update_display(); });