<div class="codetitle"> <span><a style="CURSOR: pointer" data="48295" class="copybut" id="copybut48295" onclick="doCopy('code48295')"><u>코드 복사</u></a></span> 코드는 다음과 같습니다.</div> <div class="codebody" id="code48295"> <br>(function($){ <br>$.fn .lsMovePanel= function(){ <br>var id=this.attr("id"); <br>var X=Y=0; <br>var offsetX=offsetY=0;//절대 위치<br>var OldIndex=0 ;///스토리지 원본 인덱스<br>var Temp_Li="<li id="Temp_Li" style="Background-color:#FFFFFF;border-color:#FF023C"></li>" ; <br>var Move_obj;///현재 드래그된 개체<br>$("#" id " li").each(function(i){ <br>$(this).attr("open"," 0" ); <br>//마우스 클릭<br>$(this).bind("mousedown",function(){ <br>if(event.button==1 || event.button==0){ $( this).attr("open","1");} <br>if($(this).attr("open")=="1"){ <br>$(this).css( { <br>커서: "이동", <br>불투명도: "0.7" <br>}) <br>X=event.clientX; <br>Y=event.clientY <br>offsetX=$(this ).offset().left; <br>offsetY=$(this).offset().top; <br>OldIndex=$(this).index(); 🎜> position:"absolute", <br>left:offsetX, <br>top:offsetY <br>}) <br>$("#" id " li").each(function(i){ <br>if (i==OldIndex){ <br>$(this).after(Temp_Li); <br>} <br>}) <br>} <br>});//마우스 놓기<br> $(this).bind("mouseup",function(){ <br>if(event.button==1 || event.button==0){$(this).attr("open"," 0" );} <br>if($(this).attr("open")=="0"){ <br>$("#Temp_Li").before($(this)); <br> $( this).animate({ <br>left:$("#Temp_Li").offset().left, <br>top:$("#Temp_Li").offset().top, <br>} ,300 ,function(){ <br>$("#Temp_Li").remove(); <br>$(this).css({ <br>커서:"default", <br>불투명도:"1" , <br>위치:"정적" <br>}); <br>}) <br>$("#" id " li").each(function(i){ <br>$(this). css( { <br>"border-color":"#666666" <br>}) <br>} <br>}); ).bind("mousemove",function(){ <br>if($(this).attr("open")=="1"){ <br>var current_X=current_Y=0; <br>current_X= offsetX 이벤트 .clientX-X; <br>current_Y=offsetY event.clientY-Y; <br>$(this).css({ <br>위치:"absolute", <br>left:current_X, <br>top :current_Y <br>}); <br>Move_obj=this; <br>$("#" id " li").each(function(i){ <br>if(i!=OldIndex && $(this) .attr ("id")!="Temp_Li"){ <br>var Deviation=0 <br>var Max_X=$(this).offset().left $(this).width()-Deviation; 🎜> var Min_X=$(this).offset().left 편차; <br>var Max_Y=$(this).offset().top $(this).height()-Deviation <br>var Min_Y= $( this).offset().top 편차 <br>if((event.clientX < Max_X) && (event.clientY $(Move_obj).height() > Max_Y) && (event.clientY $(Move_obj ).height() > Min_Y) && (event.clientX > Min_X) && (event.clientY < Max_Y) ){ <BR>$(this).css({ <BR>"border-color":" #FF7578 " <BR>}); <BR>//가려진 개체의 인덱스 값이 이전인지 이후인지 확인<BR>if(OldIndex>$(this).index()){ <br>$(" #Temp_Li").before ($(this)); <br>$("#Temp_Li").remove(); <br>$(this).before(Temp_Li); <br>}else{ <br> $("#Temp_Li" ).after($(this)) <br>$("#Temp_Li").remove() <br>$(this).after(Temp_Li) <br>}else{ <br>$(this).css({ <br>"border-color":"#666666" <br>}) <br>} <br>} <br>}) <br> } <br>}) ; <br>}); <br>} <br>})(jQuery) <br><br> <br>호출 예: <br><br><br> <br>코드 복사<br><br> </div> 코드는 다음과 같습니다: <br><br> <div class="codetitle"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <span><html xmlns="http://www.w3.org/1999/xhtml"> <a style="CURSOR: pointer" data="40009" class="copybut" id="copybut40009" onclick="doCopy('code40009')"><head> <u><meta http-equiv="Content-Type" content="text/html; charset=gb2312"/> </u><title></title> ><style> </a># 패널{ </span>너비:630px; </div>높이:auto; <div class="codebody" id="code40009">패딩:0px; <br>#패널 li{ <br>float:left; <br>목록 스타일: 없음; <br>폭: 100px; <br>여백: 5px <br>경계: 1px 점선; <br>텍스트 정렬:중심; 위치:정적; <br>*{ <br>글꼴 크기:12px; <br>} <br></style> ; <br><script src= "http://demo.jb51.net/jslib/jquery/jquery-1.4.2.min.js"></script> <br><script src=" http://demo.jb51.net /jslib/lsMovePanel.js"></script> <br><body> <br><div style="margin-left:100px;"> <br><ul id="패널" > <br><li style="배경-색상:#3399FF"></li> <br><li style="배경-색상:#00CCFF" ></li> <br><li style="배경-색상:#CC9900"></li> <br><li style="배경-색상:#FF6600"> /li><br><li style="배경-색상:#FFCC99"></li> <br></ul> <br><script> 🎜>$("#Panel") .lsMovePanel(); <br></body> <br><br> </div>