I am checking if jQuery is included in the document. If not I want create an element after the closing body tag.
<script type="text/javascript">
if( !(typeof jQuery === 'function') ){
var script = document.createElement('script');
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js';
script.type = 'text/javascript';
var head = document.getElementsByTagName("head")[0];
head.appendChild(script);
}
</script>
If I do this with the body tag it appends it to the top. I wanna either append it to the end of the body tag or right after closing it.
Please help.
Use
document.body.appendChild(). It will append the element at the end of the body tag.By the way, jAndy is right, there is little need to add a javascript file dynamically at the end of the body.