日期:2014-05-16 浏览次数:20460 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>拖拽_demo</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script> <script src="http://code.jquery.com/ui/1.8.23/jquery-ui.min.js" type="text/javascript"></script> <style type="text/css"> body{ background-color:#777777; color:#FFFFFF; margin:0px; padding:18px 0 0 18px; font-size:12px; font-family:Arial, Helvetica, sans-serif; } .clear{clear:both;} .ui-sortable{ background-color:#FFFFFF; border:1px solid #555555; color:#222222; width:90px; margin:0 15px 15px 0; padding:0 10px 10px; } dl.sort dt{ background-color:#666666; color:#FFFFFF; cursor::default; height:2em; line-height:2em; padding:0px 6px; position:relative; } dl.sort dd{ background-color:#FFFFD8; margin:0px; padding:3px 6px; border-bottom:1px dotted #999999; border-left:1px dotted #999999; border-right:1px dotted #999999; } table{width:70px;height:auto;float:left;border:1px solid #bfbfbf;margin:5px;} tr{width:70px;float:left;} td{width:70px;float:left;} .dl-sort-placeholder{height:50px;border: 1px dashed red;background: #fbf9ee;color: #363636;} #content{float:left; width:90px;} #sidebar{float:left; width:90px;} </style> <script type="text/javascript"> var PageLayout=function(){ this.moveUp = function(){ //向上移动子项目 var link = $(this), dl = link.parents("dl"), prev = dl.prev("dl"); if(link.is(".up") && prev.length > 0){dl.insertBefore(prev);} } this.addItem = function(){ //添加一个子项目 var sortable = $(this).parents(".ui-sortable"); var options = '<span class="options"><a class="up"><img src="up.gif" border="0"></a></span>'; var html = '<dl class="sort"><dt>Dynamic name'+options+'</dt><dd>Description</dd></dl>'; sortable.append(html).sortable("refresh").find("a.up").bind("click", this.moveUp); } this.emptyTrashCan = function(o){ //回收站 o.remove(); } this.sortableChange = function(e, ui){ if(ui.sender){ var w = $(this).width(); ui.placeholder.width(w); ui.helper.css("width",$(this).children().width()); } } this.sorta