JavaScript Object/String Playing Nicely via insertAdjacentHTML

by J. Albert Bowden

HTML

<div id="test">
    <p>Just some <span>text</span> here</p>
</div>

CSS

#test { border:1px solid blue; }
p { background:#eee; margin:5px; }
span { color:red; }

JavaScript

var str = '<p>Some more <span>text</span> here</p>',
    div = document.getElementById( 'test' );

div.insertAdjacentHTML( 'beforeend', str );