html element not shrinking with page code example

Example 1: javscript insert element after another

//insert new Element after some reference Element
function insertAfter(newElement, referenceElement) {
    referenceElement.parentNode.insertBefore(newElement, referenceElement.nextSibling);
}

//example usage
var newElement = document.createElement("div");
    newElement.innerHTML = "my New Div Text";
var myCurrentElement= document.getElementById("myElementID");
    insertAfter(newElement, myCurrentElement);

Example 2: how to set timeout for a div tag in html

<script>
  const timeout = document.getElementsByClassName('classname')
  setTimeout(hideElement, 1000) //milliseconds until timeout//
  function hideElement() {
    timeout.style.display = 'none'
</script>
<div class="classname">
  <span> &times; </span>

Tags:

Html Example