JavaScript Inserir antes
function insertBefore(newNode, existingNode) {
existingNode.parentNode.insertBefore(newNode, existingNode);
}
VasteMonde
function insertBefore(newNode, existingNode) {
existingNode.parentNode.insertBefore(newNode, existingNode);
}
// create alert div
const alert_box = document.createElement("div")
alert_box.innerText = "Not allowed!";
alert_box.className = "alert";
//get the parrent of where u wanna insert
const cont = document.querySelector(".container");
// get the element you wanna insert before
const prof = document.getElementById("profile");
// do the insert
cont.insertBefore(alert_box, prof);
// The Node.insertBefore() method inserts a node before a
// reference node as a child of a specified parent node.
let insertedNode = parentNode.insertBefore(newNode, referenceNode)
// add without creating a new element
document.getElementById('my_id')
.insertAdjacentHTML('beforebegin', 'your_html_code');