[jQuery] .bind(), .delegate(), .on()

  • 0
.bind( eventType [, eventData ], handler(eventObject) )
Def: Attach a handler to an event for the elements.
- Attaching an event handler directly to elements, so the elements must exist at the point the call to .bind() occurs.
.delegate( selector, eventType, handler(eventObject) )
Def: Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements.
- Dynamic friendly: 所有新增的元素也都會被 track 
.on( events [, selector ] [, data ], handler(eventObject) )   // prefered after v1.7
Def: Attach an event handler function for one or more events to the selected elements.
- When a selector is provided, the event handler is referred to as delegated.
- Event handlers are bound only to the currently selected elements; they must exist on the page at the time your code makes the call to .on().

沒有留言 :

張貼留言