2016-09-24 100 views

回答

1

你可以使用DraggableJquery-ui。

$(function() { 
 
    $("#draggable").draggable(); 
 
    });
<!doctype html> 
 
<html lang="en"> 
 
<head> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <title>jQuery UI Draggable - Default functionality</title> 
 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> 
 
    <link rel="stylesheet" href="/resources/demos/style.css"> 
 
    <style> 
 
    #draggable { width: 150px; height: 150px; padding: 0.5em; } 
 
    </style> 
 
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
 
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
 
</head> 
 
<body> 
 
    
 
<div id="draggable" class="ui-widget-content"> 
 
    <p>Drag me around</p> 
 
</div> 
 
    
 
    
 
</body> 
 
</html>

运行段和检查。

Here is the fiddle