jQueryUI Sortable 應(yīng)用Demo(分享)
最近工作用需要設(shè)計(jì)一個(gè)自由布局的頁(yè)面設(shè)計(jì)。我選了jQuery UI 的 sortable ,可以拖拽,自由排序 使用很方便,寫一個(gè)demo,做個(gè)記錄。
第一、單項(xiàng)目自由排序
下圖效果
代碼段:
<script type="text/javascript"> $(function () { $("#box_wrap").sortable({ helper: "clone", placeholder: "box-holdplace", sort: function (e, ui) { //排序時(shí)觸發(fā)事件 }, // handle: ".handle",//指定元素內(nèi)的某種元素才可以拖動(dòng),非常有用 }).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",//移動(dòng)時(shí)候鼠標(biāo)樣式 opacity: 0.5, //拖拽過(guò)程中透明度 placeholder: "box-holdplace",//占位符className,設(shè)置一個(gè)樣式 }).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(分享)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
解決同一頁(yè)面中兩個(gè)iframe互相調(diào)用jquery,js函數(shù)的方法
本文主要介紹了解決同一頁(yè)面中兩個(gè)iframe互相調(diào)用jquery,js函數(shù)的方法,具有很好的參考價(jià)值,需要的朋友可以看下2016-12-12JQuery省市聯(lián)動(dòng)效果實(shí)現(xiàn)過(guò)程詳解
這篇文章主要介紹了JQuery省市聯(lián)動(dòng)效果實(shí)現(xiàn)過(guò)程詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-05-05jQuery實(shí)現(xiàn)的網(wǎng)頁(yè)左側(cè)在線客服效果代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)的網(wǎng)頁(yè)左側(cè)在線客服效果代碼,涉及簡(jiǎn)單的jQuery頁(yè)面動(dòng)畫顯示與隱藏效果實(shí)現(xiàn)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-10-10jquery如何把參數(shù)列嚴(yán)格轉(zhuǎn)換成數(shù)組實(shí)現(xiàn)思路
某參數(shù)的列只有一個(gè)參數(shù),那么each是失敗,如何保證pp嚴(yán)格是數(shù)組呢,很簡(jiǎn)單var a=[pp];這一句就行了,感興趣的朋友可以參考下哈,希望可以幫助到你2013-04-04jQuery+css+html實(shí)現(xiàn)頁(yè)面遮罩彈出框
面遮罩彈出框已經(jīng)不是一個(gè)陌生的話題了,實(shí)現(xiàn)的方法大同小異多種多樣,今天用jQuery實(shí)現(xiàn)頁(yè)面遮罩彈出框,主要用的技術(shù)有JQuery,css和html,感興趣的朋友可以參考下哈2013-03-03JQuery實(shí)現(xiàn)簡(jiǎn)單的服務(wù)器輪詢效果實(shí)例
這篇文章主要介紹了JQuery實(shí)現(xiàn)簡(jiǎn)單的服務(wù)器輪詢效果,結(jié)合實(shí)例形式分析了jQuery的ajax交互結(jié)合.net處理實(shí)現(xiàn)輪詢效果的相關(guān)技巧,需要的朋友可以參考下2016-03-03jQuery 點(diǎn)擊獲取驗(yàn)證碼按鈕及倒計(jì)時(shí)功能
驗(yàn)證碼倒計(jì)時(shí)功能,在前端開發(fā)中經(jīng)常會(huì)遇到,下面小編給大家?guī)?lái)了jQuery 點(diǎn)擊獲取驗(yàn)證碼按鈕及倒計(jì)時(shí)功能,感興趣的朋友跟隨小編一起看看吧2018-09-09