Exquisite custom events for JQuery best practices _ jquery

Source: Internet
Author: User
Regarding JQuery custom events, many people have sent emails asking me if I will use them in my daily JavaScript applications, as well as specific examples of cloud computing... I happen to be responsible for the development of a visual editor recently, some of which facilitate the application of JQuery custom events, and achieved good results-streamlined Code while fully utilizing the OO principle.

This article uses an example I encountered in the actual application development process to further illustrate "when to use JQuery custom events and how to use them, at the same time, you should reply to emails from students.

Demo-Ingenious JQuery custom event
JQuery best practices-Exquisite custom events
Q: How can you easily trigger the processing logic of the click Event of a check box X without changing its current selected status?

Answer: Use a Custom Event Handler function to encapsulate the processing logic of the checkbox click event! Then, the Custom Event is triggered.

Have you ever encountered the following application scenarios?
Requirement: If A container is A, can you set whether or not the four borders of A container have their border color? "Whether or not the border" and "color change" need to be linked,
That is to say, the current set color is obtained when the border is changed, the current set border is obtained when the color is changed, and timely reflected on container.

Note: In this example, the border color is set in a uniform way. You can write down the examples for setting them separately ~
Core code:

The Code is as follows:




Border settings:
Upper
Right
Lower
Left






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.