最近不是特忙,整理一下之前做的一些效果的代碼,搞一些模板出來方便之后使用,很多效果完整版已經(jīng)找不到了,只能找到一些只兼容某些瀏覽器的版本十分遺憾,所以以后應(yīng)該多多整理。
我們提供的服務(wù)有:網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、潛山ssl等。為上1000+企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的潛山網(wǎng)站制作公司
效果如下:

雖然主要為了自己使用方便,但是如果有需要的同學(xué),遇到不明白的也可以問我。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="javascript" type="text/javascript" src="min.js"></script>
<style>
.lister{float:left;margin:20px 0 0 20px;position:realtive;border:1px solid #ccc;width:100px;height:100px}
.drag{float:left;margin:20px 0 0 20px;position:realtive;border:1px dotted #ff0000;width:100px;height:100px}
</style>
</head>
<body>
<div id='listmain' >
<div class='lister' sorder='1'><img src='1.jpg' width='100px' height='100px'></div>
<div class='lister' sorder='2'><img src='2.jpg' width='100px' height='100px'></div>
<div class='lister' sorder='3'><img src='3.jpg' width='100px' height='100px'></div>
<div class='lister' sorder='4'><img src='4.jpg' width='100px' height='100px'></div>
<div class='lister' sorder='5'><img src='5.jpg' width='100px' height='100px'></div>
<div class='lister' sorder='6'><img src='6.jpg' width='100px' height='100px'></div>
<div class='lister' sorder='7'><img src='7.jpg' width='100px' height='100px'></div>
<div class='lister' sorder='8'><img src='8.jpg' width='100px' height='100px'></div>
<div class='lister' sorder='9'><img src='9.jpg' width='100px' height='100px'></div>
</div>
<div id='drag_cont' ></div>
<script>
var _drag = {
ondrag:0,
space_order:0
}
$(document).ready(
function()
{
$.extend(
{
setcursor:function()
{
$("body").css("cursor","move");
},
delcursor:function()
{
$("body").css("cursor","default");
}
}
);
$.fn.extend(
{
make_drag:function()
{
var nowindex = $(this).attr("sorder");
var sindex = $(".drag").attr("sorder");
if($(this).attr("drag_flag") != 1)
{
$(".drag").remove();
if(nowindex>sindex)
{
$(this).after("<div class='drag'></div>");
}
else
{
$(this).before("<div class='drag'></div>");
}
$("#listmain").find("div").each(
function(i,n)
{
$(this).attr("sorder",(i+1));
}
);
}
}
}
);
$(".lister").live("mousedown",
function(e)
{
$.setcursor();
e = e || window.event;
if(e.preventDefault)
e.preventDefault();
else
e.returnvalue=false;
_drag.ondrag = 1;
_drag.space_order = $(this).attr('sorder');
$(this).attr("drag_flag",'1');
var win_scroll = $(window).scrollTop();
var xx = e.clientX;
var yy = e.clientY;
var listerbox = $(this).html();
$(this).html('').removeClass('lister').addClass('drag');
$("#drag_cont").html('').append(listerbox);
$("#drag_cont").css({'left':(xx-20)+"px",'top':(yy-20+win_scroll)+"px",'cursor':'move'});
$("#drag_cont").show();
if($(this).get(0).setCapture)
{
$(this).get(0).setCapture();
}
else if(window.captureEvents)
{
window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
}
}
);
$(document).mouseup(
function(e)
{
e = e || window.event;
var dcont = $("#drag_cont").html();
_drag.ondrag = 0;
$("#drag_cont").hide();
$(".drag").removeClass("drag").addClass("lister").attr("drag_flag",0).append(dcont);
$.delcursor();
}
);
$(document).mousemove(
function(e)
{
if(_drag.ondrag == 1)
{
e = e || window.event;
var win_scroll = $(window).scrollTop();
var xx = e.clientX;
var yy = e.clientY;
$("#drag_cont").css({'left':(xx-20)+"px",'top':(yy+win_scroll-20)+"px",'cursor':'move'});
$(".lister").each(
function()
{
var tmpPos = $(this).offset();
if(xx>=tmpPos.left && xx<=(tmpPos.left+100) && yy>=tmpPos.top && yy<=(tmpPos.top+100))
$(this).make_drag();
}
);
}
}
);
}
);
</script>
</body>
</html>
網(wǎng)頁題目:一個簡單的圖片拖拽排序效果 ----- JQUERY特效模板
標(biāo)題URL:http://www.chinadenli.net/article20/igpoco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、企業(yè)建站、企業(yè)網(wǎng)站制作、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站制作、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)