move up/down in jquery

前端 未结 3 1758
醉酒成梦
醉酒成梦 2021-01-07 08:49

I Have 5 spans i am trying to move them up/down (swap positions) in jquery

Up! 
Down!         


        
3条回答
  •  梦毁少年i
    2021-01-07 09:34

    You're trying to insert a certain span before the next one, which makes it remain on the same position...

    $("#"+LinkID).insertBefore($("#"+LinkID).prev());
    

    or

    $("#"+LinkID).insertAfter($("#"+LinkID).next()); 
    

    would be better.

提交回复
热议问题