Move containing elements up and down with jquery

后端 未结 2 1752
南旧
南旧 2021-01-02 00:11

Thanks for any help you can provide! Currently, I use a ui-sortable code to allow users to move items up and down in order. Now, I want to give each of these items a set of

2条回答
  •  感情败类
    2021-01-02 00:47

    You could try replacing your JS with something like this:

    $(".down").click(function () {
        var $parent = $(this).parents(".leg");
        $parent.insertAfter($parent.next()); 
    });
    
    $(".up").click(function () {
        var $parent = $(this).parents(".leg");
        $parent.insertBefore($parent.prev()); 
    });
    

    http://jsfiddle.net/vexw5/7/

    This is just the basics. There are no animations or anything.

提交回复
热议问题