jquery - javascript how to get the program to react to a mouse click -
so i'm making interactive clock animation, clock thing , clock. interactive part comes in when user clicks mouse anywhere on screen , clock resets began. add event listener since i'm not using buttons accomplish this? want element whole screen, without turning button (for visual purposes).
if document's <body> extends width , height of browser's window, assume case site, then... you do:
document.body.onclick = function () { ... }; or
function stopthetimer() { ... } document.body.addeventlistener('click', stopthetimer); since of visible html inside of body tag, effectively, visible inside of browser window respond click event.
if aren't sure, or if body tag doesn't fill whole window's space, can attach listener document, element contains of html (including body). so do:
document.onclick = function () { ... }; or
document.addeventlistener('click', stopthetimer); the first example allows add 1 listener of same type @ once, while second 1 allows multiple listeners of same type.
you can attach listener window object, doesn't work in < ie8, you're better off using either document or body.
Comments
Post a Comment