The element drag function implemented in javascript is hosted as the browser
Updated: July 21, 2014 16:59:36 Submission: whsnow
This article mainly introduces element dragging implemented by javascript, passing references to corresponding element objects into functions
//The host is the browser//Pass the reference to the corresponding element object into the functionfunction candrag(drager) { = function (down) { var offx = var offy = ; var offxl = - offx; var offyl = - offy; = 0;//Added condition attribute for window to resolve conflicts with click = function (move) { = - offxl + "px"; = - offyl + "px"; = "move"; condition = ( - ) + ( - ); } } = function () { = null; = "auto"; } } /*For the resolution of the contradiction between click, it is necessary to judge the condition *For example: candrag(dragger); = function () { if (!condition) { = "red"; } } * Where d01 is a child element of dragger */
Related Articles
Some data processing methods that may be commonly used in JS
This article mainly introduces some data processing methods that may be commonly used in JS. Writing a lot of knowledge can deepen your own memory. The article gives detailed example code, which has certain reference learning value for everyone to learn or use JS. If you need it, you can refer to it.2021-09-09uni-app PC widescreen adaptation solution detailed illustrations
Now uni-app finally officially supports PC widescreen. The following article mainly introduces relevant information about the PC widescreen adaptation solution of uni-app. The article introduces the example code in detail. Friends who need it can refer to it.2023-03-03Brief analysis of vue two-way binding
This article mainly introduces relevant information about vue two-way binding, which has certain reference value. Interested friends can refer to it.2017-03-03JavaScript setting amount style conversion retains two decimal places sample code
This article introduces you to setting the amount style of JavaScript, that is, retaining two decimal places. There is a good tutorial below. Friends who need it can learn about it.2013-12-12JavaScript implements dynamic form generation
This article mainly discusses in-depth with you how to use JavaScript to implement a dynamic form generator. The sample code in the article is explained in detail. If you need it, please refer to it.2024-01-01Javascript implements the method of image loading from blur to clear display
This article mainly introduces the method of using Javascript to achieve image loading from blur to clear display. It is easy to understand. Friends who need it can refer to it.2016-06-06How to elegantly cancel JavaScript asynchronous tasks
This article mainly introduces how to elegantly cancel JavaScript asynchronous tasks. The article introduces the example code in detail, which has certain reference learning value for everyone's learning or work. Friends who need it, please learn with the editor below.2020-03-03JS+JSP uses img tag call to realize the number of static page access statistics
This article mainly introduces the method of JS+JSP to realize the number of static page access statistics through img tag calls. Based on JavaScript, the function of stating the number of accesses is realized through reading and writing to TXT text files. Friends who need it can refer to it2015-12-12How to perform local debugging of WeChat official account development
This article mainly introduces how to carry out local debugging methods for WeChat official account development. The editor thinks it is quite good. Now I will share it with you and give you a reference. Let's take a look with the editor2019-06-06WeChat applet uses npm to support tricks
This article mainly introduces the use of npm support for WeChat applets to hit the pit. The editor thinks it is quite good. Now I will share it with you and give you a reference. Let's take a look with the editor2018-11-11