jQuery Sortable Move UP/DOWN Button

前端 未结 3 570
一向
一向 2020-12-13 09:41

I currently have a jQuery sortable list working perfectly. I am able to move the \'li\' elements around. However, how can I make a button to move a specific \'li\' element u

3条回答
  •  被撕碎了的回忆
    2020-12-13 10:32

    Based on @azatoth answer, if someone like to have the buttons for every record he can do it in this way (replace the li tag with your Sortable tag).

    HTML:

    
    
    

    jQuery:

    $('.my-button-up').click(function(){
        var current = $(this).closest('li');
        current.prev().before(current);
    });
    $('.my-button-down').click(function(){
        var current = $(this).closest('li');
        current.next().after(current);
    });
    

提交回复
热议问题