Answers for "js insert after element"

-1

insert element after element javascript

function insertAfter(newNode, existingNode) {
    existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);
}
Posted by: Guest on October-19-2020
0

js insert after element

var d1 = document.getElementById('one');
d1.insertAdjacentHTML('afterend', '<div id="two">two</div>');
Posted by: Guest on August-07-2021
0

js insert after element

<!DOCTYPE html>
<html>
<body>
     <p id='up'>Up</p>
    <p id="down">Down</p>
  <button id="switchBtn" onclick="switch_place()">Switch place</button>
  <script>
    function switch_place(){
      var downElement = document.getElementById("down")
      var upElement = document.getElementById("up")
      downElement.after(upElement);
      document.getElementById('switchBtn').innerHTML = "Switched!"
    }
  </script>
</body>
</html>
Posted by: Guest on August-07-2021

Code answers related to "js insert after element"

Code answers related to "Javascript"

Browse Popular Code Answers by Language