Usage and difference of bind, live and one methods in jQuery
Source: Internet
Author: User
The bind () method is used to attach a handler to the event of each Matching Element and return the jQuery object .. Bind (eventType [, evnetData], Handler (eventObject). The eventType parameter is a string that contains one or more javaScri... the SyntaxHigh bind () method is used to attach a handler to an event of each Matching Element and return the jQuery object.. In bind (eventType [, evnetData], Handler (eventObject), The eventType parameter is a string that contains one or more javaScript event types, such as click, submit or custom event name. Multiple event types are separated by spaces. eventData is of the Map type and data to be passed to the event handler is provided, handler specifies the function to be executed when the event is triggered. eventObject indicates the event object. The. bind () method attaches the event handler to an eventType event that matches each element in the element set. If necessary, it can also pass data to the event handler. The live () method attaches an event handler to a specified event that matches all elements of the current selector (including existing or future additions) and returns the jQuery object.. Live (eventType, [eventData], handler) where the eventType parameter is a string that contains one or more javaScript event types, such as click, keydown, or custom event names, eventData is an optional parameter. It is of the Map type and provides the data to be passed to the event handler. this parameter is added in jQuery1.4. handler is a function, these functions are executed when this event is triggered. the live () method attaches the event handler to the eventType event of each Matching Element (including the existing and future additions, if necessary, you can also use eventData to transmit data to the event handler.. The live () method is basic. A deformation of the bind () method. The latter can append the event handler to the element when calling. when bind (), the elements matching the jQuery object will be appended to the event handler, but the elements to be added later will not be appended to the event handler. Therefore, you also need to call these elements again. bind () method. The. one () method attaches the event handler to the specified event of the matching element and returns the jQuery object. The attached event handler can be executed only once at most.. One (eventType, [eventData], handler (eventObject), where the eventType parameter is a string that contains one or more javaScript event types, such as click, submit or custom event name. Multiple event types are separated by spaces. eventData is of the Map type and data to be passed to the event handler is provided, handler specifies the function to be executed when the event is triggered. eventObject indicates the event object. The. one () method is similar to. bind (). The difference is that the event handler bound with. one () will be automatically unbound once it is executed.
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