"Go" jquery method for registering events

Source: Internet
Author: User

Original link: Http://outofmemory.cn/code-snippet/2123/jquery-zhuce-event-method

1. Use event names to bind, the available event names are

Change,Click,DblClick,Error,Focus,focusin,focusout,< Span class= "PLN" >keydown,keypress,keyup ,mousedown,mouseenter ,mouseleave,mousemove ,mouseout,mouseovermouseup,resize, Scroll,select,submit , unload               

For example:

$(' #target ').  Click(function() {alert(' #target元素绑定了click事件 ');});      

2. Bind the event bind (TYPE,[DATA],FN) using the Bind method. The type parameter and the various event names described above for us, for example:

When each paragraph is clicked, its text pops up.

3. Using the on method to register the event, the on method is basically the same as the Bind method, in fact, the Bind method is best to invoke the on method to achieve

$('. SCV ').  On(' click ',function() {$(this).  Clone(true).  AppendTo(' #container ');});            

4. Even later add-on methods Live method

In the old jquery version, we had a way to handle event bindings for dynamically generated elements-live (), using the Live () method to apply the effects of the method bindings to existing or newly created DOM elements. The code is as follows:

$('. SCV ').  Live(' click ',function() {$(this).  Clone().  AppendTo(' #container ');});            

5. One-time event-binding method A method that binds a single-pass event handler for each matching element's specific event (like click). When all paragraphs are clicked for the first time, all their text is displayed.

$("P").  One("click",function() {alert( this).  Text());  });

"Go" jquery method for registering events

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.