> 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/traversal/swapelement.md).

# swapElement()

`swapElements()` swaps the position of two elements.

## Syntax

```javascript
swapElements(nodeA, nodeB);
```

## Parameters

* `nodeA` → first DOM element
* `nodeB` → second DOM element

## Output

```javascript
void
```

## Example

```javascript
swapElements($('#first-card'), $('#second-card'));
```

## Key Takeaway

> Use `swapElements()` when two elements need to trade places.
