Annexe sur une position spécifique
parentElement.insertBefore(newElement, parentElement.children[2]);
Arex
parentElement.insertBefore(newElement, parentElement.children[2]);
<script>
var button = false;
function myfun(){
if ( button === false){
var b1 = document.createElement("BUTTON");
b1.innerHTML = "Click Me";
document.body.appendChild(b1);
return button = true;
}
}
</script>
<p id="demo" onclick="myfun();"> click me to create button </p>
<script>
var button = false;
function myfun(){
if ( button === false){
var b1 = document.createElement("BUTTON");
b1.innerHTML = "Click Me";
document.body.appendChild(b1);
return button = true;
}
}
</script>