A summary of DOM traversal and event handling in jquery

Source: Internet
Author: User
Tags bind

1. Filter elements





























Method the returned element
. Filter (selector) elements that match selector
. Filter (CALLBAXK) The element that returns true in callback
. EQ (Index) Index selected element counting starting at 0
. A () The first element in the selected element
. Last () The last element of the selected element
. Slice (Start[,end]) The selected element in the given range counting from the 0 start
. Not (selector) Elements that do not match the selector
. has (selector) Descendant elements that match the selector

2. Descendant elements















Method the returned element
. Find (selector) Descendant elements that match the selector
. Contents () Child nodes (including text nodes)
. Children ([selector]) Child nodes, which can be passed into selector for filtering

3. Sibling elements



























Method the returned element
. Next ([selector]) The next element immediately adjacent to each selected element can be passed into selector for filtering
. Nextall ([selector]) All sibling elements after each selected element can be passed into selector for filtering
. Nextuntil ([Selector],[filter]) After each selected element, until it does not contain the first and selector matching elements, you can filter by passing in the filter
. prev ([selector]) The last element next to each selected element can be filtered in selector
. Prevall ([selector]) All sibling elements before each selected element can be passed into selector for filtering
. Prevuntil ([Selector],[filter]) Filters can be filtered in before, until and without first and selector matching elements per selected element
. siblings ([selector]) All sibling elements, which can be passed into selector for filtering

4. Ancestral elements





















Method the returned element
. parent ([selector]) The parent element of each selected element, which can be passed into selector for filtering
. parents ([selector]) All ancestor elements of each selected element, which can be passed into selector for filtering
. Parentsuntil ([Selector],[filter]) Filters can be filtered by all ancestor elements of each selected element until they contain the first and selector matching elements.
. Closest (selector) The first element that matches the selector and searches the ancestor element up the DOM number from the element itself
. offsetparent () The first parent element (relative or absolute) to which the selected element is defined

5. Set operation





















Method Description
. Add ([selector]) Add elements that match selector to the original object collection
. Addback () Selected Elements plus the previously selected elements in the jquery internal stack
. End () Elements previously selected in the internal jquery stack
. Map (callback) After each check calls the callback function callback the result
. Pushstack () The specified element

6. Operation of selected elements

































Method Description
. Is (selector) Determines if there are incoming elements in the matched element that match the selector
. Index () Gets the index of the matching element relative to its sibling element
. Index (Element) Gets the index of the DOM node in the matching element with the specified element object
$.contains (A,B) Determine if DOM Node A contains DOM node B
. each (callback) Iteration matching elements, executing callback for each element
. length Gets the number of matching elements
. Get () Gets a list of DOM nodes corresponding to the matching elements
. Get (Index) Gets the DOM node in the matching element that corresponds to the specified index
. ToArray () Gets a list of DOM nodes corresponding to the matching elements

7. Event Binding




































Between
Method Description
. Ready (handler) Dom and CSS after full load handler
. On (type,[selector],[data],ha Ndler) to bind the type event and specify the event handler handler, and if the selector is specified, execute the event delegate
. On (Events,[selector],[data]) bind multiple event handlers based on events of event objects
. Off (type,[selector],handler) dismiss an event handler on an element bound
. bind (Type,[data],handler) binding type events and specifying event handlers handler
. One (Type,[data) , handler) binds the type event and specifies that the event handler Handler,handler be unbound immediately after being invoked
. Unbind ([Type],[handler]) unbind the specified event handler from bind to the element (not specified to remove all specified)
. Delegate (Selector,type,[data],handler) binds the type event to the element that matches selector and specifies the event handler handler
. Delegate (selector,handlers) binds the type event to the element that matches selector and specifies the event handler handlers
. Undelegate (Selector,type,[handler]) to remove delegate specified event handler for element binding

8. Other methods















Method Description
. Trigger (Type,[data]) Triggers an event on an element and performs the default action for the event
. Triggerhandler (Type,[data]) Triggers an event on an element, but does not perform the default action for the event
$.proxy (Fn,context) Creates a new function to execute in the specified context.

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.