jQuery UI Draggable + Sortable 結(jié)合使用(實(shí)例講解)
工作中需要將一個(gè)左邊的設(shè)計(jì)好的控件,拖拽到右邊的面板中,同時(shí)保持右邊面板中的控件自由排序,這時(shí)候就需要及支持拖拽又支持排序的操作了,
Demo截圖:從左邊控件拖到右邊區(qū)域
代碼段:
<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(); $(".dragable").draggable({ connectToSortable: ".sortable", helper: "clone", // revert: "invalid", // handle: ".handle" }); }); </script>
Html 代碼:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <link href="js/bootstrap/css/bootstrap.css" rel="external nofollow" rel="stylesheet" /> <link href="js/bootstrap/css/bootstrap-theme.min.css" rel="external nofollow" rel="stylesheet" /> <link href="css/index.css" 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 dragable"> left-test1 </div> <div class="box dragable"> left-test2 </div> <div class="box dragable"> left-test3 </div> </div> </div> <div class="column col-md-6"> <div class="box_wrap sortable" id="box_wrap2"> <div class="box"> test1 </div> <div class="box"> test2 </div> <div class="box"> test3 </div> </div> </div> </div> </div> </body> </html>
以上這篇jQuery UI Draggable + Sortable 結(jié)合使用(實(shí)例講解)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
基于Jquery實(shí)現(xiàn)表格動(dòng)態(tài)分頁(yè)實(shí)現(xiàn)代碼
項(xiàng)目中經(jīng)常會(huì)對(duì)表格進(jìn)行分頁(yè),以下運(yùn)用jquery對(duì)用戶(hù)管理中的用戶(hù)表格進(jìn)行分頁(yè)。2011-06-06基于Jquery和html5實(shí)現(xiàn)炫酷的3D焦點(diǎn)圖動(dòng)畫(huà)
這篇文章主要介紹了基于Jquery和html5實(shí)現(xiàn)炫酷的3D焦點(diǎn)圖動(dòng)畫(huà)的相關(guān)資料,焦點(diǎn)圖中的圖片利用了CSS3的相關(guān)特性實(shí)現(xiàn)圖片傾斜效果,從而讓圖片出現(xiàn)3D的視覺(jué)效果,感興趣的小伙伴們可以參考一下2016-03-03jquery的ajaxSubmit()異步上傳圖片并保存表單數(shù)據(jù)演示代碼
使用jquery的ajaxSubmit()異步上傳圖片的捅死實(shí)現(xiàn)保存表單數(shù)據(jù),具體演示代碼如下,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助2013-06-06jQuery實(shí)現(xiàn)IE輸入框完成placeholder標(biāo)簽功能的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)IE輸入框完成placeholder標(biāo)簽功能的方法,涉及jQuery事件響應(yīng)及針對(duì)頁(yè)面元素屬性的動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2017-09-09z-blog SyntaxHighlighter 長(zhǎng)代碼無(wú)法換行解決辦法(基于jquery)
這篇文章主要介紹了z-blog SyntaxHighlighter 長(zhǎng)代碼無(wú)法換行解決辦法(jquery),需要的朋友可以參考下2015-11-11jquery如何解決resize執(zhí)行兩次的問(wèn)題
這篇文章主要介紹了jquery如何解決resize執(zhí)行兩次的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-07-07jQuery ReferenceError: $ is not defined 錯(cuò)誤的處理辦法
今天開(kāi)始要學(xué)習(xí)jQuery,寫(xiě)第一個(gè)Hello Word時(shí),居然jQuery ReferenceError: $ is not defined2013-05-05