Bài 06: Tạo đồng hồ đếm ngược với hàm setTimeout() trong Javascript - 1
RUN
<!DOCTYPE html> <html> <head> <title>Đồng hồ đếm ngược bằng JS</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style> span{border: solid 1px #ACACAC; padding: 2px;} </style> <script language="javascript"> var h = null; // Giờ var m = null; // Phút var s = null; // Giây var timeout = null; // Timeout function start() { // Code } function stop(){ clearTimeout(timeout); } </script> </head> <body> <div> <strong> Nhập thông tin ban đầu: <br/> </strong> <input type="text" id="h_val" placeholder="Giờ" value=""/> <br/> <input type="text" id="m_val" placeholder="Phút" value=""/> <br/> <input type="text" id="s_val" placeholder="Giây" value=""/> <input type="button" value="Start" onclick="start()"/> <input type="button" value="Stop" onclick="stop()"/> <br/> <br/> </div> <div> <span id="h">Giờ</span> : <span id="m">Phút</span> : <span id="s">Giây</span> </div> </body> </html>
PHÓNG TO