网站导航免费论文 原创论文 论文搜索 原创论文 网学软件 学术大家 资料中心 会员中心 问题解答 原创论文 论文素材 设计下载 最新论文 下载排行 论文上传 在线投稿 联系我们
返回网学首页
最新论文 推荐专题 热门论文 素材专题
当前位置: 网学 > 网页素材 > AJAX代码 > 正文
jquery应用实例之图片拖拽排序
来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 11/01/18

最近在研究Interface elements for jQuery(http://interface.eyecon.ro/),此插件封装了一些拖拽效果,并且使用非常简单,能轻松实现拖拽排序、购物车、博客首页排版等UI,所以模仿和讯的图片排序做了一个简单示例.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Sortables demo - Interface plugin for jQuery</title>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="interface.js"></script>
<style type="text/css" media="all">
body
{}{
    background: #fff;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
}
#sort1
{}{
    width: 350px;
    height: 200px;
}
div img  
{}{
    float: left;
    width: 60px;
    height: 60px;
    margin:10px;
    border:solid 3px #ccc;
}
.sorthelper
{}{
    background-color: #f5f5f5;
    float: left;
    border:4px solid #ccc;
}
.sortableactive
{}{
}
.sortablehover
{}{
}
</style>
</head>
<body>
<div id="sort1">
    <img src=http://www.aspxcs.net/HTML/"1.jpg" class="sortableitem" id="1" alt="1"/>
    <img src=/uploadfile/201101/18/64105338500.jpg" class="sortableitem" id="2" alt="2"/>
    <img src=/uploadfile/201101/18/31105338134.jpg" class="sortableitem" id="3" alt="3"/>
    <img src=/uploadfile/201101/18/80105338262.jpg" class="sortableitem" id="4" alt="4"/>
    <img src=/uploadfile/201101/18/82105338603.jpg" class="sortableitem" id="5" alt="5"/>
    <img src=/uploadfile/201101/18/F5105338104.jpg" class="sortableitem" id="6" alt="6"/>

</div>
<div  class="serializer">
<a href="#" onClick="serialize(); return false;" >提交排序</a>
</div>
<script type="text/javascript">
$(document).ready(
    function () {
        $(''#sort1'').Sortable(
            {
                accept :         ''sortableitem'',   //拖拽元素class名
                helperclass :     ''sorthelper'',     //拖拽时投放位置的样式  
                activeclass :     ''sortableactive'', //拖拽时悬空时class
                hoverclass :     ''sortablehover'',  //拖拽时经过时class
                opacity:         0.5,              //拖拽时透明度      
                fx:                200,              //拖拽时回位速度
                revert:            true,
                floats:            true,
                tolerance:        ''pointer'',
                onchange:       changedata         //拖拽状态改变时触发事件
            }
        )
    }
);
function changedata()
{
}

function serialize(s)
{
    serial = $.SortSerialize(s);
    alert(serial.hash.replace(/&sort1\[\]=/g,",").replace("sort1=",""));
    /**//*这里可使用jquery form插件ajax提交
    (http://www.malsup.com/jquery/form/#code-samples)
       使用也非常方便
    */
};
</script>    
</body>
</html>

  • 上一篇资讯: ajax简单调用web服务示例
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 电话:013574892963 QQ:3710167 邮箱:Educs@163.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 Www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号