insertbefore() code example
Example 1: js insertbefore
let insertedNode = parentNode.insertBefore(newNode, referenceNode)
Example 2: insert into
INSERT INTO client (prenom, nom, ville, age)
VALUES
('Rébecca', 'Armand', 'Saint-Didier-des-Bois', 24),
('Aimée', 'Hebert', 'Marigny-le-Châtel', 36),
('Marielle', 'Ribeiro', 'Maillères', 27),
('Hilaire', 'Savary', 'Conie-Molitard', 58);
Example 3: js insert before
const alert_box = document.createElement("div")
alert_box.innerText = "Not allowed!";
alert_box.className = "alert";
const cont = document.querySelector(".container");
const prof = document.getElementById("profile");
cont.insertBefore(alert_box, prof);
Example 4: javascript insertBefore
<div id="parentElement">
<span id="childElement">foo bar</span>
</div>
<script>
let sp1 = document.createElement("span")
let sp2 = document.getElementById("childElement")
let parentDiv = sp2.parentNode
parentDiv.insertBefore(sp1, sp2)
</script>