Java Reference
In-Depth Information
background-color: red;
Now create a js folder that contains a file called scripts.js for our JavaScript code. Place the
following inside:
function doSomething(){
console.log("Something Happened!");
addEventListener("click", doSomething);
Try opening events.htm in a browser with the console open and click anywhere on the page.
You should see this message in the console:
"Something Happened!"
Note: Global Event Listeners
Event listeners are usually called as a method of a particular element on the
page. If there's no element calling them, they are global and apply to the
whole page.
Search WWH ::

Custom Search