In some recent projects, I have often encountered the need to sort elements, including: Move Up, Move down, top, bottom. So how does this work?
Move up, in short, the position of the element that needs to be moved up and its front element, using InsertBefore (), the general idea is:
var dom= the element that needs to be moved up; var domprev=dom.prev ();d om.insertbefore (Domprev);
Move down, similar to move up, will need to move down the element and the element behind it exchange position, using InsertAfter (), the approximate idea is:
var dom= the element that needs to be moved down; var domnext=dom.next ();d om.insertafter (Domnext);
Top, the first child that will need the top element to become its parent element, using Prependto (), the general idea is:
var dom= the element that needs to be pinned, Var domparent=dom.parent ();d om.prependto (domparent), bottom, similar to top, the last child that will need to turn the bottom element into its parent element, using Appendto (), The general idea is:
Var dom= requires a base element, Var domparent=dom.parent ();d om.appendto (domparent), InsertBefore (), InsertAfter (), Prependto (), AppendTo () can implement these simple sorting operations on the element.
Sort operations such as move up, move down, and so on for an element