Sniper method to move an element to the beginning of it family
The toFirst() function moves a specified HTML element to the first position among its sibling elements within the same parent.
toFirst()
$('selector').toFirst();
selector: The element to be moved.
Move the 4th list item to the beginning of its list:
$('ul li:nth-child(4)').toFirst();
The moved element.
By calling toFirst() on an element, the element is relocated to the beginning of its parent container, maintaining the DOM hierarchy smoothly.
Last updated 1 year ago