jquery Learning Essays (Event objects)

Source: Internet
Author: User

$ (' input '). Bind (' click ', Function (e) {

Alert (E.type)//result is click

Alert (typeof E.type)//Returns a string

})

Target is the DOM that gets the trigger element, the trigger element, which is the one you ordered.

Currenttarget gets the DOM of the listener element, which is the one you're bound to.

For example:

$ (' div '). bind (' click ', Function (e) {        alert (e.target);           When the mouse clicks on the div area, it pops up an  object htmldivelement
When the mouse clicks on the span area, it pops up objecthtmlspanelement

$ (' div '). bind (' click ', Function (e) {        alert (e.currenttarget);           When the mouse clicks on the div area, it pops up an  object htmldivelement
When the mouse clicks on the span area, it pops up objecthtmldivelement

$ (' div '). MouseOver (function (e) {        alert (e.relatedtarget);           When the mouse moves out of the span area to the Div area, an  object is ejected htmlspanelement
When the mouse moves from the div area into the span area, it pops up objecthtmldivelement
Mainly in the process of moving the mouse to move the previous element and mouseout the opposite, is the end of the mouse movement process of the element of the stay
<div style= "Width:200px;height:200px;background: #ccc;" ><span style= "Width:100px;height:100px;background:red;display:block;" ></span></div>

Data usage

$ (' div '). bind (' click ', 123,function (e) {   alert (e.data);    Pop-up Result 123}) The argument can be an array, a string, an object

Page Origin: The upper-left corner of the visible area (consistent with the viewport where the scroll bar is not present)

Display: Entire browser, including toolbar

Viewport: Visible area (the area where the page is normally browsed, excluding toolbars)

The green area is the display, the red area is the viewport, the origin of the page is orange, when the scroll bar appears, Pagey and clienty are not the same, Pagey also need to add the distance between the scroll bar and the top

jquery Learning Essays (Event objects)

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.