1.jquery adding events to dynamically added elements
In the new version of JQuery, before using. On (), we used. Live () to bind events for dynamically added code, but now jquery replaces. On (). Live ()
Let's look at A. Live () instance
function () {$ ("#111"). Append ("OK");});
Look at an instance of. On ()
function () { $ ("#111"). Append ("OK");});
Of these,. Live () is similar to. On () before 1.7, while the 1.9. On () method is on (EVENTS,[SELECTOR],[DATA],FN), you can specify which parent node the binding is on, and then write the element selector to go in the subsequent selector
Live principle:
. Live () is bound to an element by way of an event delegate. More appropriate for the list type, bound to the document DOM node. and. Bind () have the advantage of supporting dynamic data.
2.event.originalevent JQuery
Today in the use of jquery E.pagex, found that the value has been undefined, Baidu a bit, replaced by the E.originalevent.pagex is good, the problem is solved, but do not know why, so in the stack Overflow on the search, here for everyone to translate.
Event.originalevent is the native JS event, and if the browser is compatible or is used on a device that can be touched, the API is usually burst to event.originalevent. Simply put, event.originalevent will behave differently depending on the trigger time type and the browser's operating environment.
As an example:
var // Gives error:trying to get property of undefined var // Works Fine
jquery does not encapsulate some of the APIs for native event objects, just the files in the example. So at such times we need to use event.originalevent.
3. Touch Events
There are three basic touch events that are listed in the specification and have been widely implemented across mobile devices:
1. Touchstart: Place your finger on a DOM element.
2. Touchmove: Drag a DOM element with your finger.
3. Touchend: Move the finger away from a DOM element.
Each touch event includes three touch lists:
1. Touches: A list of all the fingers that are currently on the screen.
2. Targettouches: A list of the fingers that are located on the current DOM element.
3. Changedtouches: A list of fingers that involve the current event.
For example, in a Touchend event, this would be a moving finger.
These lists consist of objects that contain touch information:
1. Identifier: A numeric value that uniquely identifies the current finger in a touch session.
2. The Target:dom element is the target of the action.
3. Client/page/screen coordinates: The position where the action takes place on the screen.
4. Radius coordinates and RotationAngle: Draw an ellipse roughly equivalent to the shape of a finger.
A summary of JQuery Mobile to realize the function of Apple sliding Delete alarm