I'd suggest get the parent node using JS and then replace an entire node with another node that you've built.
Manipulating DOM by replacing HTML could be dangerous if any JS is depending on any part of that.
Or use oldChild.replaceWith(newChild)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.