toFirst()
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.
Usage
$('selector').toFirst();selector: The element to be moved.
Example
Move the 4th list item to the beginning of its list:
$('ul li:nth-child(4)').toFirst();Returns
The moved element.
Description
By calling toFirst() on an element, the element is relocated to the beginning of its parent container, maintaining the DOM hierarchy smoothly.
Last updated