欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery實(shí)現(xiàn)表格行的上下移動(dòng)和置頂

 更新時(shí)間:2022年02月22日 10:01:22   作者:每天進(jìn)步一點(diǎn)_點(diǎn)  
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)表格行的上下移動(dòng)和置頂,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了jquery實(shí)現(xiàn)表格行的上下移動(dòng)和置頂?shù)木唧w代碼,供大家參考,具體內(nèi)容如下

先上效果圖:

點(diǎn)擊上移、下移、置頂,可以實(shí)現(xiàn)對(duì)應(yīng)的效果。

上代碼:

<td>
? ? <a href="javascript:" data-opt="delete" class="layui-btn layui-btn-mini layui-btn-danger">刪除</a>
? ? {{# if(index > 0){ }} ?//layui的模板語法
? ? <a href="javascript:" data-opt="moveup" class="layui-btn layui-btn-mini">上移</a>
? ? <a href="javascript:" data-opt="movetop" class="layui-btn layui-btn-mini">置頂</a>
? ? <a href="javascript:" data-opt="movedown" style="display: none;" class="layui-btn layui-btn-mini">下移</a>
? ? {{# } else if(index ==0){ }}
? ? <a href="javascript:" data-opt="movedown" ?class="layui-btn layui-btn-mini">下移</a>
? ? <a href="javascript:" data-opt="moveup" style="display: none;" ?class="layui-btn layui-btn-mini">上移</a>
? ? <a href="javascript:" data-opt="movetop" style="display: none;" ?class="layui-btn layui-btn-mini">置頂</a>
? ? {{# } }}
</td>
$('#content').children("tr").each(function (index) {
? ? var $that_tr=$(this);
? ? var diseaseDoctorId=$that_tr.data("id");
? ? ? $that_tr.children("td:last-child").children("a").each(function () {
? ? ? ? ? var $that_a=$(this);
? ? ? ? ? var action=$that_a.data("opt");
? ? ? ? ? ?$that_a.on('click',function (e) {
? ? ? ? ? ? ?switch (action){
? ? ? ? ? ? ? ?case 'delete':
? ? ? ? ? ? ? ?var name = $that.parent('td').siblings('td[data-field=name]').text();
? ? ? ? ? ? ? ? //詢問框
? ? ? ? ? ? ??layerTips.confirm('確定要?jiǎng)h除[ <span style="color:red;">' + name + '</span> ] ?', { icon: 3, title: '系統(tǒng)提示' }, function (index) {


? ? ? ? ? ? ? ? ? ? $.ajax({
? ? ? ? ? ? ? ? ? ? ? ? ?url:'<%=staticPath%>/doctor/diseaseDoctor/delere/'+diseaseDoctorId,
? ? ? ? ? ? ? ? ? ? ? ? ?type:'get',
? ? ? ? ? ? ? ? ? ? ? ? ? dataType:'json',
? ? ? ? ? ? ? ? ? ? ? ? ? success:function (result) {
? ? ? ? ? ? ? ? ? ? ? ? ? ?if (result.code==200) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?layer.msg("刪除成功");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?location.reload();
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?else
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?layer.msg("刪除失敗");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?},
? ? ? ? ? ? ? ? ? ? ? ? ? ?error:function (result) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?layer.msg("刪除失敗");
? ? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?});
? ? ? ? ? ? ? ? ? ? ? ? ? ?});
? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ? ? ? ?case 'moveup':
? ? ? ? ? ? ? ? ? ? ? ? ? ?console.log("上移");
? ? ? ? ? ? ? ? ? ? ? ? ? ?var prev=$that_a.parents("tr").prev();
? ? ? ? ? ? ? ? ? ? ? ? ? ?var prevIndex=$(prev).index('tr');
? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.parents("tr").insertBefore(prev);

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if(prevIndex==1){
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.prop("style","display:none");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.siblings("a[data-opt=movetop]").prop("style","display:none");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.siblings("a[data-opt=movedown]").prop('style','display:');
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$(prev).children("td:last-child").find("a[data-opt=movedown]").prop("style","display:none");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? $(prev).children("td:last-child").find("a[data-opt=moveup]").prop("style","display:");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? $(prev).children("td:last-child").find("a[data-opt=movetop]").prop("style","display:");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}

? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ? ? ? ?case 'movetop':
? ? ? ? ? ? ? ? ? ? ? ? ? ?console.log("置頂");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?var first=$that_a.parents("tr").siblings("tr:first");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.parents("tr").insertBefore(first);
? ? ? ? ? ? ? ? ? ? ? ? ? ?$(first).children("td:last-child").find("a[data-opt=movedown]").prop("style","display:none");
? ? ? ? ? ? ? ? ? ? ? ? ? ?$(first).children("td:last-child").find("a[data-opt=moveup]").prop("style","display:");
? ? ? ? ? ? ? ? ? ? ? ? ? ?$(first).children("td:last-child").find("a[data-opt=movetop]").prop("style","display:");
? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.siblings("a[data-opt=moveup]").prop("style","display:none");
? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.prop("style","display:none");
? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.siblings('a[data-opt=movedown]').prop("style","display:");
? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ? ? ? ?case 'movedown':
? ? ? ? ? ? ? ? ? ? ? ? ? ?console.log("下移");
? ? ? ? ? ? ? ? ? ? ? ? ? ?var next=$that_a.parents("tr").next();
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.parents("tr").insertAfter(next);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.siblings("a[data-opt=moveup]").prop("style","display:");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.siblings("a[data-opt=movetop]").prop("style","display:");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$that_a.prop("style","display:none");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$(next).children("td:last-child").find("a[data-opt=moveup]").prop("style","display:none");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$(next).children("td:last-child").find("a[data-opt=movetop]").prop("style","display:none");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$(next).children("td:last-child").find('a[data-opt=movedown]').prop("style","display:");


? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? });
? ? });
});

我是做后臺(tái)的,js寫的可能比較 low,各位看看即可,歡迎提出修改意見。

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論