I have a page that call a script such as :
<script src="http://www.mypage.com/widget/script.js" type="text/javascript"></script>
inside this script I get the current “script” on execution, with :
var scripts = document.getElementsByTagName('script');
var myScript = scripts[scripts.length - 1];
now, what I’d like to do, is to add after this “element” (I mean, after the script in my calling page) a new one, such as :
<div>New Element</div>
so the final result in my page will be :
<script src="http://www.mypage.com/widget/script.js" type="text/javascript"></script>
<div>New Element</div>
how can I do it? I think I’ll wrap myScript with jquery, but don’t know how to add a new element after this one in the DOM.
1 Answer