Java Reference
In-Depth Information
Types of Events
There are several types of events, ranging from when a video has finished playing to when a
resource has completed downloading. You can see a full list on the Events page of the Moz-
illa Developer Network.
In this section we are going to focus on some of the more common events that occur using
the mouse, the keyboard, and touch.
Mouse Events
We have already seen the click event that occurs when a mouse button is clicked. There is
also the mousedown event, which occurs before the click and the mouseup event, occur-
ring after the click.
This can be seen by adding this code to events.js:
var click = document.getElementById("click");
console.log("click") });
console.log("up") });
There is also the dblclick event, which occurs when the user double-clicks on the ele-
ment to which the event listener is attached. To see an example of this, we'll attach an event
listener to the second paragraph in our example (with an ID of ' dblclick '). Add the fol-
lowing code to scripts.js:
var dblclick = document.getElementById("dblclick");
dblclick.addEventListener("dblclick", highlight);
function highlight(event){
Search WWH ::

Custom Search