首页 > 代码库 > js 上移下移行

js 上移下移行

function up_tr(sender) {
                            var tr = $(sender).parent().parent();
                            var table = tr.parent();
                            var first = $("tr:first", table);
                            if (tr.html() == first.html()) {
                                alert("已經是第一行了");
                            } else {
                                tr.prev().insertAfter(tr);
                            }
                        }
                        function down_tr(sender) {
                            var tr = $(sender).parent().parent();
                            var table = tr.parent();
                            var last = $("tr:last", table);
                            if (tr.html() == last.html()) {
                                alert("已經是最後一行了");
                            } else {
                                tr.next().insertBefore(tr);
                            }
                        }