上下移动jquery

来源:互联网 发布:英文版软件 编辑:程序博客网 时间:2024/05/17 17:16
 /*
     *  use:客服列表页面上下移动list
     *  creat:haoxj@xinfushe.com
     *  on:2016.6.12
     */
    ;(function($) {
        var productsLabel = {
            clc: function() {
                var that = this;
                $('.table tbody tr td').on('click', '.btn-up', function() {
                    var _this = this;
                    that.setUp(_this)
                })
                $('.table tbody tr td').on('click', '.btn-down', function() {
                    var _this = this;
                    that.setDown(_this)
                })
            },
            //设置置顶 
            // setHot: function(t) {
            //     var bar = 'item-list';
            //     var obj = $(t).parents('.' + bar).clone(true);
            //     $(t).parents('.' + bar).remove();
            //     $(".tbody-list-box").prepend(obj);
            // },


            //设置上移 
            setUp: function(t) {
                var bar = 'item-list';
                if ($(t).parents('.' + bar).prev('.' + bar).html() != undefined) {
                    var obj = $(t).parents('.' + bar).clone(true);
                    $(t).parents('.' + bar).prev().before(obj);
                    $(t).parents('.' + bar).remove();
                } else {
                    alert('亲,现在已是最上的哦,不能再上移了...');
                }
            },


            //设置下移 
            setDown: function(t) {
                var bar = 'item-list';
                if ($(t).parents('.' + bar).next('.' + bar).html() != undefined) {
                    var obj = $(t).parents('.' + bar).clone(true);
                    $(t).parents('.' + bar).next().after(obj);
                    $(t).parents('.' + bar).remove();
                } else {
                    alert('亲,现在已是最下的哦,不能再下移了...');
                }
            }
        }
        productsLabel.clc();
    })($)
})
0 0