参考地址:https://www.runoob.com/jqueryui/jqueryui-tutorial.html
1、上下拖曳排序
代码如下所示
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI 排序(Sortable) - 默认功能</title>
<link rel="stylesheet" href="jquery-ui-1.10.3.custom.css">
<script src="jquery.min.js"></script>
<script src="jquery-ui-1.10.3.custom.js"></script>
<link rel="stylesheet" href="jqueryui/style.css">
<style>
#sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
#sortable li { margin: 3px 3px 3px 0; padding: 1px; font-size: 30px; text-align: center; }
li{
background-color: #EAF6FE;
color: #108CEE;
padding: 5px 5px 5px 15px;
margin: 5px 0;
font-size: 13px;
cursor: pointer;
}
</style>
<script>
$(function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
});
</script>
</head>
<body>
<ul id="sortable">
<li class="">1</li>
<li class="">2</li>
<li class="">3</li>
<li class="">4</li>
<li class="">5</li>
<li class="">6</li>
</ul>
</body>
</html>
2:上下左右拖曳排序
代码如下所示
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI 排序(Sortable) - 默认功能</title>
<link rel="stylesheet" href="jquery-ui-1.10.3.custom.css">
<script src="jquery.min.js"></script>
<script src="jquery-ui-1.10.3.custom.js"></script>
<link rel="stylesheet" href="jqueryui/style.css">
<style>
li{
background-color: #EAF6FE;
color: #108CEE;
padding: 5px 5px 5px 15px;
margin: 5px 0;
font-size: 13px;
cursor: pointer;
}
#sortable { list-style-type: none; margin: 0; padding: 0; width: 450px; }
#sortable li { margin: 3px 3px 3px 0; padding: 1px; float: left; width: 100px; height: 90px; font-size: 4em; text-align: center; }
</style>
<script>
$(function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
});
</script>
</head>
<body>
<ul id="sortable">
<li class="">1</li>
<li class="">2</li>
<li class="">3</li>
<li class="">4</li>
<li class="">5</li>
<li class="">6</li>
<li class="">7</li>
<li class="">8</li>
<li class="">9</li>
<li class="">10</li>
<li class="">11</li>
<li class="">12</li>
</ul>
</body>
</html>