Implementation of the drag and drop function of JQueryUI _ jquery

Source: Internet
Author: User
JQueryUI is a WebUI code library officially supported by JQuery. It contains underlying interaction, animation, special effects, and other APIs, and encapsulates some Web widgets ). At the same time, JQueryUI inherits the support of jquery plug-ins. A large number of third-party plug-ins can enrich the JQueryUI function. The APIS provided by JQuery UI greatly simplify the development of drag-and-drop functions. You only need to call the draggable and droppable functions on the source and target respectively.

Drag Principle
First, we need to clarify several concepts.
Ource: drag the source, the element to be dragged.
Taerget: drag and drop the target, which can be placed into the source container.
The drag action is broken down as follows:
1. drag start: click the mouse on the drag source and start to move
2. drag move: Moving
3. drag enter: Move to the target container
4. drag leave: remove the target container
5. drop: Release the mouse on the target container
6. drag end: end
Before html5, page elements do not support drag and drop events. Therefore, the drag function is implemented by listening to mouse events and recording the drag status.

Simplest example
The simplest drag operation is to change the position of an element without changing its container. Example:

The Code is as follows:







Drag me!




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.