jq进行table动态增删上下移动
来源:互联网 发布:算法基础 pdf 下载 编辑:程序博客网 时间:2024/06/04 20:10
$(function () {
$('#insertRow').click(function () {
var $tr = $('#templateTr').clone(true);
$tr.attr('id', '');
$('#columnid tbody').append($tr);
$tr.show();
});
$('#columnid .delrow').click(function () {
var $tr = $(this).parents("tr");
$tr.remove();
});
$('#columnid .moveup').on('click', function () {
$(this).each(function () {
var $tr = $(this).parents("tr");
if ($tr.index() != 0) {
$tr.prev().before($tr);
}
});
});
$('#columnid .movedown').on('click', function () {
var trLength = $(this).length;
$(this).each(function () {
var $tr = $(this).parents("tr");
if ($tr.index() != trLength - 1) {
$tr.next().after($tr);
}
});
});
});
<a class="btn btn-primary btn-sm" id="insertRow" href="javascript:void(0);">
<span class="glyphicon glyphicon-plus"></span> 新增
</a>
<table id="columnid" class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr id="trcolumn">
<th>字段名称</th>
<th class="col-sm-1">字段类型</th>
<th>属性</th>
<th>参与主键</th>
<th class="col-sm-2">操作</th>
</tr>
</thead>
<tbody>
<tr id="templateTr" style="display: none;">
<td><input type="text" class="form-control input-sm" placeholder="请输入字段名称" /></td>
<td>
<select class="form-control input-sm">
<option value="1">数字</option>
<option value="2">字符</option>
<option value="3">日期</option>
</select>
</td>
<td><input type="text" class="form-control input-sm" placeholder="如果是字符,填字符长度;如果是日期,填日期格式" /></td>
<td><label class="checkbox-inline"><input type="checkbox" name="bePk" />参与主键</label></td>
<td>
<a class="btn btn-primary btn-xs delrow" href="javacript:void(0);"><span class="glyphicon glyphicon-trash"></span> 删除</a>
<a class="btn btn-primary btn-xs moveup" href="javascript:void(0);"><span class="glyphicon glyphicon-arrow-up"></span> 上移</a>
<a class="btn btn-primary btn-xs movedown" href="javascript:void(0);"><span class="glyphicon glyphicon-arrow-down"></span> 下移</a>
</td>
</tr>
</tbody>
</table>
- jq进行table动态增删上下移动
- table tr的上下移动
- javascript动态增删Table
- js 动态增删table
- js table动态增删
- table行的上移下移 上下移动
- jquery 控制table tr 上下移动
- table的数据行tr上下移动
- 动态增删table行示例代码
- html table tr td 上下移动行实例源代码
- jquery操作table 数据行拷贝,和上下移动
- Jquery 关于table整行上下移动的代码
- PHP+JQ+AJAX+json 数据库实时动态增删改查
- JQ判断上下滑动
- jq 文字上下滚动
- js 上下键控制table里tr的背景上下移动选中效果
- 上下移动
- gvim/vim在同一行进行上下移动
- 缓存雪崩,缓存穿透,缓存预热,缓存热备都是什么鬼?
- 金融系统中正确的金额计算及存储方式
- 【资源更新】Hadoop全套教程
- 高级教程分享:Dubbo+Zookeeper+ActiveMQ+Redis等。
- 智能蛇
- jq进行table动态增删上下移动
- 5分钟带你理解一致性Hash算法。
- Spring Boot集成Mybatis双数据源
- Spring Boot配置加载顺序
- 剑指offer-36-数组中的逆序对
- Spring Boot配置随机数
- HashMap 源码解析
- 分布式服务防雪崩熔断器,Hystrix理论+实战。
- GitHub上11月份最热门的Java项目