转载自:http://blog.csdn.net/wang4978/article/details/6721157

<html>
<head>
<title>拖动行测试</title>
<script type="text/javascript">
var beginMoving = false;
function MouseDownToMove(obj) {
obj.style.zIndex = ;
obj.mouseDownY = event.clientY;
obj.mouseDownX = event.clientX;
beginMoving = true;
obj.setCapture();
} function MouseMoveToMove(obj) {
if (!beginMoving) return false;
obj.style.top = (event.clientY - obj.mouseDownY);
obj.style.left = (event.clientX - obj.mouseDownX);
} function MouseUpToMove(obj) {
if (!beginMoving) return false;
obj.releaseCapture();
obj.style.top = ;
obj.style.left = ;
obj.style.zIndex = ;
beginMoving = false;
var tempTop = event.clientY - obj.mouseDownY;
var tempRowIndex = (tempTop - tempTop % ) / ;
if (tempRowIndex + obj.rowIndex < ) tempRowIndex = -;
else tempRowIndex = tempRowIndex + obj.rowIndex;
if (tempRowIndex >= obj.parentElement.rows.length - ) tempRowIndex = obj.parentElement.rows.length - ;
obj.parentElement.moveRow(obj.rowIndex, tempRowIndex);
}
</script> </head> <body>
<table id="filelistTab" cellspacing="" cellpadding="" border=>
<tr>
<td class="gridtitle" style="WIDTH: 40px">列一</td>
<td class="gridtitle" style="WIDTH: 100px">列二</td>
<td class="gridtitle" style="WIDTH: 110px">列三</td>
</tr> <tr id="" title="拖动行可以进行排序" style="cursor:move ;position:relative;" onmousedown='MouseDownToMove(this)' onmousemove='MouseMoveToMove(this)' onmouseup='MouseUpToMove(this);'>
<td class="gridtitle"><input class="text" id="group1" style="WIDTH: 30px" type="text" readonly value="" /></td>
<td class="gridtitle"> </td>
<td class="gridtitle"><input class="text" id="fn1" readOnly type="text" style="width:100px" value="" /></td>
</tr> <tr id="" title="拖动行可以进行排序" style="cursor:move ;position:relative;" onmousedown='MouseDownToMove(this)' onmousemove='MouseMoveToMove(this)' onmouseup='MouseUpToMove(this);'>
<td class="gridtitle"><input class="text" id="group2" style="WIDTH: 30px" type="text" readonly value="" /></td>
<td class="gridtitle"> </td>
<td class="gridtitle"><input class="text" id="fn2" readOnly type="text" style="width:100px" value="" /></td>
</tr> <tr id="" title="拖动行可以进行排序" style="cursor:move ;position:relative;" onmousedown='MouseDownToMove(this)' onmousemove='MouseMoveToMove(this)' onmouseup='MouseUpToMove(this);'>
<td class="gridtitle"><input class="text" id="group3" style="WIDTH: 30px" type="text" readonly value="" /></td>
<td class="gridtitle"> </td>
<td class="gridtitle"><input class="text" id="fn3" readOnly type="text" style="width:100px" value="" /></td>
</tr> <tr id="" title="拖动行可以进行排序" style="cursor:move ;position:relative;" onmousedown='MouseDownToMove(this)' onmousemove='MouseMoveToMove(this)' onmouseup='MouseUpToMove(this);'>
<td class="gridtitle"><input class="text" id="group4" style="WIDTH: 30px" type="text" readonly value="" /></td>
<td class="gridtitle"> </td>
<td class="gridtitle"><input class="text" id="fn4" readOnly type="text" style="width:100px" value="" /></td>
</tr> <tr id="" title="拖动行可以进行排序" style="cursor:move ;position:relative;" onmousedown='MouseDownToMove(this)' onmousemove='MouseMoveToMove(this)' onmouseup='MouseUpToMove(this);'>
<td class="gridtitle"><input class="text" id="group5" style="WIDTH: 30px" type="text" readonly value="" /></td>
<td class="gridtitle"> </td>
<td class="gridtitle"><input class="text" id="fn5" readOnly type="text" style="width:100px" value="" /></td>
</tr> <tr id="" title="拖动行可以进行排序" style="cursor:move ;position:relative;" onmousedown='MouseDownToMove(this)' onmousemove='MouseMoveToMove(this)' onmouseup='MouseUpToMove(this);'>
<td class="gridtitle"><input class="text" id="group6" style="WIDTH: 30px" type="text" readonly value="" /></td>
<td class="gridtitle"> </td>
<td class="gridtitle"><input class="text" id="fn6" readOnly type="text" style="width:100px" value="" /></td>
</tr> </table>
</body>
</html>

转载:javascript 拖拽排序,简洁示例备忘的更多相关文章

  1. dragsort html拖拽排序

    一.Jquery List DragSort 对于有些页面,如首页的定制,需要进行动态的拖拽排序.由于自己实现比较困难,我们一般会使用一些js插件来实现.dragsort 就是帮助我们完成这一需求.通 ...

  2. html5 Sortable.js 拖拽排序源码分析

    最近公司项目经常用到一个拖拽 Sortable.js插件,所以有空的时候看了 Sortable.js 源码,总共1300多行这样,写的挺完美的.   本帖属于原创,转载请出名出处. 官网http:// ...

  3. jQuery可拖拽排序列表jquery-sortable-lists

    jquery-sortable-lists可以通过鼠标进行拖动排列树型菜单,可以定义某个列表元素是否拖动,拖动后回调,点击可以折叠树型结点,可以用来在后台模仿wordpress后台拖动菜单,实现多级菜 ...

  4. 使用knockout-sortable实现对自定义菜单的拖拽排序

    在开始之前,照例,我们先看效果和功能实现. 关于自定义菜单的实现,这里就不多说了,需要了解的请访问:http://www.cnblogs.com/codelove/p/4838766.html 这里需 ...

  5. jquery sortTable拖拽排序

    所有的事件回调函数都有两个参数:event和ui,浏览器自有event对象,和经过封装的ui对象   ui.helper - 表示sortable元素的JQuery对象,通常是当前元素的克隆对象   ...

  6. zTree的拖拽排序

    ztree本身是可以支持拖拽的,但是却没有找到明确的支持拖拽的排序,也就是说,在拖拽过程中,需要自定义维护拖拽后的顺序并保存至后台. 在这样一个比较常规的需求情况下,网上也有朋友给出了一些解决方案,比 ...

  7. RecyclerViewItemTouchHelperDemo【使用ItemTouchHelper进行拖拽排序功能】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 记录使用ItemTouchHelper对Recyclerview进行拖拽排序功能的实现. 效果图 代码分析 ItemTouchHel ...

  8. easyui树节点拖拽排序的存储过程

    easyui树的拖拽排序功能 easyui树中有拖拽功能 树结构如下: 一个行政区域对应一个单位,一个单位对应多个部门,每个部门下有相关人员,功能要求: (1)行政区域没有子节点,点击text加载部门 ...

  9. React造轮子:拖拽排序组件「Dragact」

    先来一张图看看: 项目地址:Github地址 (无耻求星!) 在线观看(第一次加载需要等几秒):预览地址 说起来不容易,人在国外没有过年一说,但是毕竟也是中国年,虽然不放假,但是家里总会主内一顿丰盛的 ...

随机推荐

  1. Ubuntu 14.10 下设置静态IP

    修改 /etc/network/interfaces 文件 sudo nano /etc/network/interfaces 修改为 # 前面的不变auto eth0 iface eth0 inet ...

  2. Note_Master-Detail Application(iOS template)_07_ YJYDetailViewController.m

    //  YJYDetailViewController.m #import "YJYDetailViewController.h" @interfaceYJYDetailViewC ...

  3. 多数求和(java)

    实验题目:从命令行接受多个数字,求和之后输出结果. 设计思想:命令行输入的字符会赋值给args数组,所以在命令行输入数字后,直接取出args的数组长度,作为循环语句的终点判断,然后利用循环将字符型改为 ...

  4. ubuntu 新系统需要做的事

    1 : 打开语言支持 开始补齐并且选择自己需要的语言包 . 2 : 搜索计算机 输入 update 找到软件更新器 更新软件库 . 然后打开ubuntu自带软件安装工具下载自己想要的软件(没有更新之前 ...

  5. BZOJ 2054 疯狂的馒头

    并查集把染过色的并在一起.倒着染色. #include<iostream> #include<cstdio> #include<cstring> #include& ...

  6. Generic method return type

    Here's the Animal class: public class Animal{ private Map<String,Animal> friends =new HashMap& ...

  7. 【LeetCode OJ】Best Time to Buy and Sell Stock

    Problem Link: http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/ We solve this problem ...

  8. List<T>Contains, Exists, Any之间的优缺点对比

    在List<T>中,Contains, Exists, Any都可以实现判断元素是否存在. 性能方面:Contains 优于 Exists 优于 Any 测试的代码: public sta ...

  9. python类的定义和使用

    python中类的声明使用关键词class,可以提供一个可选的父类或者说基类,如果没有合适的基类,那就用object作为基类. 定义格式: class 类名(object): "类的说明文档 ...

  10. 【转】博弈问题及SG函数(真的很经典)

    博弈问题若你想仔细学习博弈论,我强烈推荐加利福尼亚大学的Thomas S. Ferguson教授精心撰写并免费提供的这份教材,它使我受益太多.(如果你的英文水平不足以阅读它,我只能说,恐怕你还没到需要 ...