> For the complete documentation index, see [llms.txt](https://jscula.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jscula.gitbook.io/docs/manipulation/.tofirst.md).

# .toFirst()

A Jscula method to move an element to the beginning of its family

The `toFirst()` function moves a specified HTML element to the first position among its sibling elements within the same parent.

#### Usage

```javascript
$('selector').toFirst();
```

* **selector**: The element to be moved.

#### Example

Move the 4th list item to the beginning of its list:

```javascript
$('ul li:nth-child(4)').toFirst();
```

#### Use cases

Use `toFirst()` to:

* Pin an important notification above other messages.
* Move a selected item to the top of a result list.
* Prioritize an urgent task in a task list.

#### More examples

Move a pinned notification to the top of its panel:

```javascript
$('.notification.pinned').toFirst();
```

Move the selected search result to the top:

```javascript
$('.search-result.selected').toFirst();
```

Move an urgent task ahead of other tasks:

```javascript
$('.task.urgent').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.
