In the same way as looking completely at it sideways, I suggest avoiding the oddities / complexity of breeding and reducing the problem.
Setting content in hidden (i.e. <div id="replacements">...</div> ). Take innerHTML from the node you want and do with it.
It's a lot easier to get replacement content from non-devs too, it seems to work great if you're on a team.
// Probably better in a separate helpers.js file. function replaceContentInContainer(target, source) { document.getElementById(target).innerHTML = document.getElementById(source).innerHTML; }
Control it with: (lose href=javascript: and use onClick, better as an event handler , but for brevity I will include it as an onClick attribute and use a button.)
<button onClick="replaceContentInContainer('target', 'replace_target')">Replace it</button>
We have our goal somewhere in the document.
<div id="target">My content will be replaced</div>
Substitution content is then hidden inside the div div.
<div id="replacements" style="display:none"> <span id="replace_target"><a href="http://address.com">superlink</a></span> </div>
Here he is in jsbin
Improve the dynamic nature of this using Handlebars or another beautiful JS template library, but this is an exercise for the OP.
edit: Note that you must also name functions with a leading lowercase letter and reserve a leading uppercase style for class names, for example. var mySweetInstance = new MySpecialObject();
ocodo
source share