使用jquery寫(xiě)個(gè)更改表格行順序的小功能
更新時(shí)間:2014年04月29日 17:11:35 作者:
這篇文章主要介紹了使用jquery寫(xiě)的更改表格行順序的小功能,需要的朋友可以參考下
周末寫(xiě)了個(gè)更改表格行順序的小功能,直接貼代碼
表格部分如下:
<table class="table" id="test_table">
<thead>
<tr>
<th>時(shí)間</th>
<th>詳情</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr cid="7.0.0-2014-04-29_11-02-24_123" class="list_line">
<td>
2014-04-29 11:02:24
</td>
<td>
詳情
</td>
<td>
<span class="move_btn glyphicon glyphicon-arrow-up" move_act="up"></span>
<span class="move_btn glyphicon glyphicon-arrow-down" move_act="down"></span>
</td>
</tr>
<tr cid="7.0.0-2014-04-29_11-02-24_915" class="list_line">
<td>
2014-04-28 10:00:00
</td>
<td>
詳情
</td>
<td>
<span class="move_btn glyphicon glyphicon-arrow-up" move_act="up"></span>
<span class="move_btn glyphicon glyphicon-arrow-down" move_act="down"></span>
</td>
</tr>
</tbody>
</table>
js代碼,其中會(huì)為要變更的行在變更順序后加上class=danger
<script type="text/javascript">
$(function(){
$('.move_btn').click(function(){
var move_act = $(this).attr('move_act');
$('#test_table tbody tr').removeClass('danger');
if(move_act == 'up'){
$(this).parent().parent('tr').addClass('danger')
.prev().before($(this).parent().parent('tr'));
}
else if(move_act == 'down'){
$(this).parent().parent('tr').addClass('danger')
.next().after($(this).parent().parent('tr'));
}
setTimeout("$('#test_table tbody tr').removeClass('danger');", 2000);
});
});
</script>
更改后可以按照每行的唯一標(biāo)記提交新的順序
吐槽:喊著加班=狼性的公司都是不適合正常人類生存的公司,把周末加班當(dāng)成鼓吹的事情&評(píng)價(jià)員工是否有狼性的標(biāo)準(zhǔn)更是扯淡。
表格部分如下:
復(fù)制代碼 代碼如下:
<table class="table" id="test_table">
<thead>
<tr>
<th>時(shí)間</th>
<th>詳情</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr cid="7.0.0-2014-04-29_11-02-24_123" class="list_line">
<td>
2014-04-29 11:02:24
</td>
<td>
詳情
</td>
<td>
<span class="move_btn glyphicon glyphicon-arrow-up" move_act="up"></span>
<span class="move_btn glyphicon glyphicon-arrow-down" move_act="down"></span>
</td>
</tr>
<tr cid="7.0.0-2014-04-29_11-02-24_915" class="list_line">
<td>
2014-04-28 10:00:00
</td>
<td>
詳情
</td>
<td>
<span class="move_btn glyphicon glyphicon-arrow-up" move_act="up"></span>
<span class="move_btn glyphicon glyphicon-arrow-down" move_act="down"></span>
</td>
</tr>
</tbody>
</table>
js代碼,其中會(huì)為要變更的行在變更順序后加上class=danger
復(fù)制代碼 代碼如下:
<script type="text/javascript">
$(function(){
$('.move_btn').click(function(){
var move_act = $(this).attr('move_act');
$('#test_table tbody tr').removeClass('danger');
if(move_act == 'up'){
$(this).parent().parent('tr').addClass('danger')
.prev().before($(this).parent().parent('tr'));
}
else if(move_act == 'down'){
$(this).parent().parent('tr').addClass('danger')
.next().after($(this).parent().parent('tr'));
}
setTimeout("$('#test_table tbody tr').removeClass('danger');", 2000);
});
});
</script>
更改后可以按照每行的唯一標(biāo)記提交新的順序
吐槽:喊著加班=狼性的公司都是不適合正常人類生存的公司,把周末加班當(dāng)成鼓吹的事情&評(píng)價(jià)員工是否有狼性的標(biāo)準(zhǔn)更是扯淡。
您可能感興趣的文章:
相關(guān)文章
MVC+jQuery.Ajax異步實(shí)現(xiàn)增刪改查和分頁(yè)
這篇文章主要為大家詳細(xì)介紹了MVC結(jié)合jQuery.Ajax異步實(shí)現(xiàn)增刪改查和分頁(yè)的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05jQuery+CSS實(shí)現(xiàn)的table表格行列轉(zhuǎn)置功能示例
這篇文章主要介紹了jQuery+CSS實(shí)現(xiàn)的table表格行列轉(zhuǎn)置功能,涉及jQuery事件響應(yīng)及頁(yè)面元素屬性動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-01-01jquery查找父元素、子元素(個(gè)人經(jīng)驗(yàn)總結(jié))
對(duì)使用js或者jquery查找父元素、子元素比較混淆的朋友可以參考下本文,因?yàn)槭莻€(gè)人總結(jié),用起來(lái)會(huì)比較方便2014-04-04jquery tools系列 overlay 學(xué)習(xí)
接著上次scrollable的學(xué)習(xí),今天繼續(xù)jquery tools六大功能的第四個(gè)功能——overlay的學(xué)習(xí)。2009-09-09酷炫jQuery全屏3D焦點(diǎn)圖動(dòng)畫(huà)效果
這篇文章主要介紹了一款非??犰诺膉Query全屏3D焦點(diǎn)圖動(dòng)畫(huà)效果其特點(diǎn)是整個(gè)焦點(diǎn)圖基本是全屏顯示的,非常大氣,感興趣的小伙伴們可以參考一下2016-03-03jQuery EasyUI NumberBox(數(shù)字框)的用法
jQuery EasyUI 數(shù)字框(NumberBox)用法2010-07-07