jQueryUI Sortable 應(yīng)用Demo(分享)
最近工作用需要設(shè)計一個自由布局的頁面設(shè)計。我選了jQuery UI 的 sortable ,可以拖拽,自由排序 使用很方便,寫一個demo,做個記錄。
第一、單項目自由排序
下圖效果

代碼段:
<script type="text/javascript">
$(function () {
$("#box_wrap").sortable({
helper: "clone",
placeholder: "box-holdplace",
sort: function (e, ui) {
//排序時觸發(fā)事件
},
// handle: ".handle",//指定元素內(nèi)的某種元素才可以拖動,非常有用
}).disableSelection();
});
</script>
html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="js/bootstrap/css/bootstrap.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" />
<link href="js/bootstrap/css/bootstrap-theme.min.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" />
<link href="css/index.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" />
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/bootstrap/js/bootstrap.min.js"></script>
<!--Sortable -->
<script src="http://apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
</head>
<body>
<div class="box_wrap" id="box_wrap">
<div class="box">
test1
</div>
<div class="box">
test2
</div>
<div class="box">test3
</div>
</div>
</body>
</html>
第二、多排序組之間自由拖拽

代碼段:
<script type="text/javascript">
$(function () {
$("#box_wrap1,#box_wrap2").sortable({
connectWith: ".box_wrap",
helper: "clone",
cursor: "move",//移動時候鼠標(biāo)樣式
opacity: 0.5, //拖拽過程中透明度
placeholder: "box-holdplace",//占位符className,設(shè)置一個樣式
}).disableSelection();
});
</script>
html 代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="js/bootstrap/css/bootstrap.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" />
<link href="js/bootstrap/css/bootstrap-theme.min.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" />
<link href="css/index.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" />
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/bootstrap/js/bootstrap.min.js"></script>
<!--Sortable -->
<script src="http://apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="column col-md-6">
<div class="box_wrap" id="box_wrap1">
<div class="box">
left-test1
</div>
<div class="box">
left-test2
</div>
<div class="box">
left-test3
</div>
</div>
</div>
<div class="column col-md-6">
<div class="box_wrap" id="box_wrap2" >
<div class="box">
test1
</div>
<div class="box">
test2
</div>
<div class="box">
test3
</div>
</div>
</div>
</div>
</div>
</body>
</html>
上面另種是工作中比較常用的排序形式。
以上這篇jQueryUI Sortable 應(yīng)用Demo(分享)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
jquery實現(xiàn)標(biāo)簽支持圖文排列帶上下箭頭按鈕的選項卡
這篇文章主要介紹了jquery實現(xiàn)標(biāo)簽支持圖文排列帶上下箭頭按鈕的選項卡的特效,效果十分不錯,而且非常實用,有需要的小伙伴參考下吧。2015-03-03
jquery實現(xiàn)頁面百葉窗走馬燈式翻滾顯示效果的方法
這篇文章主要介紹了jquery實現(xiàn)頁面百葉窗走馬燈式翻滾顯示效果的方法,實例分析了jQuery操作百葉窗翻滾效果的實現(xiàn)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-03-03
JQuery頁面的表格數(shù)據(jù)的增加與分頁的實現(xiàn)
使用JQuery實現(xiàn)頁面的表格數(shù)據(jù)的增加與分頁,具體示例如下,喜歡的朋友可以參考下2013-12-12
Spring shiro + bootstrap + jquery.validate 實現(xiàn)登錄、注冊功能
這篇文章主要介紹了Spring shiro + bootstrap + jquery.validate 實現(xiàn)登錄、注冊功能,需要的朋友可以參考下2017-06-06
jQuery Validate設(shè)置onkeyup驗證的實例代碼
jQuery Validate 插件為表單提供了強(qiáng)大的驗證功能,讓客戶端表單驗證變得更簡單,同時提供了大量的定制選項,滿足應(yīng)用程序各種需求。這篇文章主要介紹了jQuery Validate設(shè)置onkeyup驗證的相關(guān)資料,需要的朋友可以參考下2016-12-12
jQuery中json對象的復(fù)制方式介紹(數(shù)組及對象)
本文為大家介紹下jQuery中json對象的復(fù)制:jQuery自帶的$.map方式、深復(fù)制與淺復(fù)制等等,感興趣的朋友可以參考下哈,希望對大家有所幫助2013-06-06

