<!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>
<title></title>
<link href="js/jquery-ui-1.12.1/jquery-ui.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table id="sort" class="table">
<thead class="table-header">
<tr>
<td class="index" style="width: 20px;">序号</td>
<td style="width: 150px;">缩略图</td>
<td style="width: 500px;">图片介绍</td>
</tr>
</thead>
<tbody class="table-body">
<tr class=" drag" >
<td class="index"></td>
<td>
<img src="" width="100px"
height="100px">
</td>
<td>
<input type="text" ng-model="foo.content" maxlength="200"
style="width: 100%"/>
</td>
</tr>
<tr class=" drag" >
<td class="index"></td>
<td>
<img src="" width="100px"
height="100px">
</td>
<td>
<input type="text" ng-model="foo.content" maxlength="200"
style="width: 100%"/>
</td>
</tr>
</tbody>
</table>
<script src="js/jquery-ui-1.12.1/external/jquery/jquery.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.12.1/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () { sortable(); });
function sortable() {
var fixHelperModified = function (e, tr) {
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function (index) {
$(this).width($originals.eq(index).width())
});
return $helper;
},
updateIndex = function (e, ui) {
$('td.index', ui.item.parent()).each(function (i) {
$(this).html(i + 1);
});
};
$("#sort tbody").sortable({
cursor: "move",
items: "tr", //只是tr可以拖动
opacity: 0.6, //拖动时,透明度为0.6
helper: fixHelperModified,
stop: updateIndex
}).disableSelection();
}
</script>
</body>
</html>