我是html和jquery的新手...我想在div1,div2之类的另一个下面创建3个div的一个...而且div应该是可拖动的,现在我想将div1拖到一个位置div3 ..现在订单应该是div3,div1,div2,......我怎么能这样做?
请帮帮我......
<html>
<head>
<title>My First Template </title>
<style type="text/css">
html {
background: url(Software.png) no-repeat center center fixed;
-webkit-background-size: 100%;
-moz-background-size: 100%;
-o-background-size: 100%;
background-size: 100%;
}
</style>
<link rel="stylesheet" href="stylesheets/jquery.sidr.dark.css">
<script src="jquery.js" ></script>
<script src="jquery.sidr.min.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="SignUp.css">
<script src="jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() {
$("#div1").draggable();
$("#div2").draggable();
$("#div3").draggable();
$("#div4").draggable();
});
</script>
</head>
<body>
<div id="div1" style="position: relative; left: 850px; top: 100px; width: 500px; height: 100px; background-color: white">div1</div>
<div id="div2" style="position: relative; left: 850px; top: 150px; width: 500px; height: 100px; background-color: blue">div2</div>
<div id="div3" style="position: relative; left: 850px; top: 200px; width: 500px; height: 100px; background-color: green">div3</div>
<div id="div4" style="position: relative; left: 850px; top: 250px; width: 500px; height: 100px; background-color: red">div4</div>
</body>
</html>
答案 0 :(得分:2)
最简单的方法:http://jqueryui.com/sortable/
以下是jQuery示例中的代码:
$(function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
});