Complete jquery drag-and-drop effect example (with demo source code download), jquerydemo

Source: Internet
Author: User

Complete jquery drag-and-drop effect example (with demo source code download), jquerydemo

This document describes the drag and drop effects implemented by jquery. We will share this with you for your reference. The details are as follows:

The running effect is as follows:

Click here to view Online Demo results.

The Code is as follows:

Html section:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">

Jquery section:

(function(){ $.fn.extend({  tuoz:function(){  return this.each(function(){    var $this=$(this);    var ey="";    var ex="";    var mx="";    var my="";    var tx="";    var ty="";    var small_x="";    var small_y="";    var big_height="";    var big_width="";    var big_x="";    var big_y="";    var move="false";    $this.mousedown(function(e){     move="true";     mx=$this.offset().left;     my=$this.offset().top;     ex=e.clientX;     ey=e.clientY;     tx=ex-mx;     ty=ey-my;     small_x=$("#big").offset().left;     small_y=$("#big").offset().top;     big_height=$("#big").height();     big_width=$("#big").width();     big_x=small_x+big_width;     big_y=small_y+big_height;     })    $(document).mousemove(function(e){      ex=e.clientX;      ey=e.clientY;      if(move=="true"){      $this.offset({left:ex-tx,top:ey-ty});      }      })    $this.mouseup(function(e){      move=false;      ex=e.clientX;      ey=e.clientY;      if(ex>=small_x && ey>=small_y && ex<=big_x && ey<=big_y){    $("#big").append($this.html());    }      $this.offset({left:mx,top:my});      })    })  }  })})(jQuery)

Click here to download the complete instance code.

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.