Edit in JSFiddle

var container = document.getElementById('container'),
    paragraphToReplace = document.getElementById('paragraph'),
    newParagraph = document.createElement('p'),
    textNode = document.createTextNode('Replaced!');

newParagraph.appendChild(textNode);
container.replaceChild(newParagraph, paragraphToReplace);
<div id="container">
    <p id="paragraph">Element to replace</p>
    <p>Stay here :)</p>    
<div>