JQuery can drag the div to implement the Code script house revision _ jquery

Source: Internet
Author: User
After studying jQuery recently, I think it is really a very good js library. The key is to have a detailed document, which is very important. Of course, the Code is also very convenient to use, so you don't have to worry about a lot of things.
In the course of study, jQuery is used to implement a p drag, and the code is appended to the end of this article.
For implementation ideas, refer to my DIV (2) that can be dragged.
When referring to the examples in the jQuery Chinese website, I found that when they triggered the click event in the title bar of the p window, they moved the position of p to some of them, the mouseup event is registered in the entire p window. This idea inspired me to solve the error caused by moving the mouse fast and p cannot keep up with. It is a very good solution.
In addition, pay attention to event bubbles. In jQuery and any js Code that implements p-drag, event bubbles will undoubtedly be blocked.
In the bind or unbind method of jQuery, it is best to use false for the return value of the function. If you do not believe it, try true.
In general code, we use the stopPropagation method to prevent this event bubble process.
:

Note that the jquery-1.2.6.js is loaded

The Code is as follows:


Related Article

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.