HTML DOM Event Object

Source: Internet
Author: User
Tags event listener

HTML DOM Event Object

Event Object

The event object represents the state of the incident, such as the element in which the event occurred, the state of the keyboard key, the position of the mouse, and the state of the mouse button.

Events are often used in conjunction with functions, and functions are not executed until the event occurs!

Event Source

The element that triggered the event

Behavior that the event was detected by JavaScript

Event Example:-Mouse click-Hover over a hotspot on the page-keyboard key-Confirm form-Select an input box in the form

Event handler function

One of the new features of HTML 4.0 is the ability to enable HTML events to trigger behavior in the browser, such as starting a piece of JavaScript when the user clicks on an HTML element. Also called "Event handle" or "event listener"

Event classification

offsetx,offsety: The x-coordinate and y-coordinate of the location of the event that occurred in the coordinate system of the event source element.

Clientx,clienty: The event property returns the coordinates of the mouse pointer to the browser page (or client area) when the event is triggered ...

Screenx,screeny: event property returns the coordinates of the mouse pointer relative to the screen when an event occurs.

Preventdefault () method

Cancels the default action for the event.

Grammar:

event.preventDefault()

Stoppropagation () method

No more events are being dispatched.

The termination event is further propagated during the capture, target processing, or bubbling phase of the propagation process. After the method is called, the handler that handles the event on that node is called, and the event is no longer dispatched to the other node.

Grammar

event.stopPropagation()

Cancelbubble This property must be set to TRUE if the event handle wants to prevent the event from propagating to the containment object.

oEvent.cancelBubble=true;

HTML DOM Event Object

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.