DOM Element.prepend() Method
The prepend() method adds one or more nodes or text strings at the start of an element, before its first child.
Description
The prepend() method inserts nodes or strings before the first child of the element. Like append(), it accepts several arguments and treats strings as text.
The arguments are inserted in the order given, so el.prepend(a, b) puts a first and b straight after it, before any existing children. Strings are inserted as text nodes, never parsed as HTML.
If a node you prepend is already in the document, it's moved rather than copied. To insert at a position in the middle, use before() or after() on a sibling, or insertBefore() on the parent.
Syntax
element.prepend(param1, param2, ...)Parameters
- param1, param2, ...Nodes or strings to add at the start.
Return Value
None (undefined).
Example
Browser Support
The following information will show you the current browser support for the Element.prepend() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





