Javascript:div Layer Drag Effect

Source: Internet
Author: User

div Layer Drag:

Realize:

Css:

View Code
<style>div {position:relative;} </style>

Js:

View Code
<script type= "Text/javascript" >varMouseover=truevarXcoor;varYcoor;functioncoordinates () {if(Event.srcElement.id.indexOf ("wishbroad") = = 0) {Event.srcElement.style.zIndex= 1000; MouseOver=true; Pleft=Event.srcElement.style.pixelLeft; Ptop=Event.srcElement.style.pixelTop; Xcoor=Event.clientx; Ycoor=Event.clienty; Document.onmousemove=Moveimage; }}functionMoveimage () {if(mouseover&&event.button==1) {Event.srcElement.style.pixelLeft=pleft+event.clientx-Xcoor; Event.srcElement.style.pixelTop=ptop+event.clienty-Ycoor; return false; }}functionMouseUp () {Event.srcElement.style.zIndex= 1; MouseOver=false;} Document.onmousedown=Coordinates;document.onmouseup=MouseUp;</script>

Html:

View Code
<HTML><Head>div Layer Drag</Head><Body><DivID= "Wishbroad1"style= "width:200px; height:100px;border:1px solid black;background:gray;">China</Div><DivID= "Wishbroad2"style= "width:200px; height:100px;border:1px solid red;background:red;">United States</Div><DivID= "Wishbroad3"style= "width:200px; height:100px;border:1px solid red;background:green;">Japan</Div><DivID= "Wishbroad4"style= "width:200px; height:100px;border:1px solid red;background:pink;">Brazil</Div></Body></HTML>

Note: for reference only. Not considering compatibility, IE9 test pass! Google is not moving! Other self-test.

CSS: CSS drop-down menu effect without JS implementation

JavaScript: Nine Kinds of JS popup dialog box

Common JavaScript

JavaScript: Exporting a table to Excel

jquery table interlaced background and highlighting when moving forward

jquery randomly generates dynamic vertical bar voting results

jquery China provinces and cities no refresh three level linkage query

Javascript:div Layer Drag Effect

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.