Use the jquey Drag Control draggable

Source: Internet
Author: User

The main purpose of this example is to use the draggable control of jquey.

Jquery, jquery-ui, and draggable are referenced in sequence. Then write the correspondingCodeFor more information about the code, seeProgram.

For draggable instructions, see: http://docs.jquery.com/UI/API/1.8/Draggable

 

Source code:Download

<% @ Page Language = " C # " Autoeventwireup = " True " Codebehind = " Default. aspx. CS " Inherits = " Jquerydrag. _ default "   %>

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head Runat = "Server" >
< Title > </ Title >

script type =" text/JavaScript " SRC =" JS/jquery-1.4.2.min.js " > script >

<ScriptType= "Text/JavaScript"SRC= "JS/jquery-ui-1.8.custom.min.js"> </Script>

<ScriptType= "Text/JavaScript"SRC= "JS/draggable. js"> </Script>

< Script Type = "Text/JavaScript" >
$ (Document). Ready ( Function (){
// Drag Method
$ ( " # Imgdrag " ). Draggable ({
// Drag range
Containment: " # Dragarea " ,
// Start event
Start: Function (Event, UI ){
Startdrag (event, UI );
},
// End event
Stop: Function (Event, UI ){
Enddrag (event, UI );
}
})
});

// Start event Method
Function Startdrag (event, UI ){
$ ( " # Startdraginfo " Pai.html ( " Start: left: "   + Ui. offset. Left +   " On: "   + Ui. offset. Top );
}
// End event Method
Function Enddrag (event, UI ){
$ ( " # Enddraginfo " Pai.html ( " End: left: "   + Ui. offset. Left +   " On: "   + Ui. offset. Top );
}

</ Script >

</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >
<% -- Draggable reference manual http: // Docs.jquery.com / UI / API / 1.8 / Draggable -- %>
<% -- Drag range -- %>
< Div ID = "Dragarea" Style = "Width: 500px; Height: 500px; Border: 1px solid blue" >
<% -- Record the information at the start of the drag -- %>
< Div ID = "Startdraginfo" >
</ Div >
<% -- Record the information at the end of the drag -- %>
< Div ID = "Enddraginfo" >
</ Div >
< BR />
< BR />
<% -- Dragged object -- %>
< IMG ID = "Imgdrag" SRC = "Img/imggreen.gif"   />
</ Div >
</ Form >
</ Body >
</ Html >

 

 

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.