Created
October 9, 2016 11:01
-
-
Save bitsmanent/dd7aaed7db08b4b700125884895f4933 to your computer and use it in GitHub Desktop.
Append a node inside another taking care of scripts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function append(where, what) { | |
| var i, len, scripts, script, p, att; | |
| where.appendChild(what); | |
| scripts = $("script", what); | |
| len = scripts.length; | |
| for(i = 0; i < len; ++i) { | |
| script = document.createElement("script"); | |
| script.innerHTML = scripts[i].innerHTML; | |
| for(att in scripts[i].atts) | |
| script[att] = scripts[i][att]; | |
| p = scripts[i].parentNode; | |
| p.insertBefore(script, scripts[i]); | |
| p.removeChild(scripts[i]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment