Why does the Node.replaceChild method indicate that replaceChild is null?

<!--  -->
<div id="outerContainer">
    <div>
        <h1>This one thing will change your life!!!</h1>
    </div>
</div>

<div id="footer">
    <div class="share">
        

something

<img src="" alt="-sharp"> </div> </div>
<script>
    var newElement = document.createElement("p");
    newElement.textContent = "p";
    
    var oldElement = document.querySelector(".share");
    oldElement.parentNode.replaceChild(newElement,oldElement);
    
    console.log(oldElement.parentNode.replaceChild(newElement,oldElement));
</script>

Mar.24,2022

oldElement has been replaced.


oldElement still retains the original reference to HTML Element
, but it was no longer mounted on the dom node when you operated replaceChild

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b459-e7cd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b459-e7cd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?