Dynamically load Jquery into .js page

Posted by RussP on Stack Overflow See other posts from Stack Overflow or by RussP
Published on 2010-04-13T10:15:52Z Indexed on 2010/04/13 10:23 UTC
Read the original article Hit count: 392

Filed under:
|
|

Please excuse me if I'm simple here, I want to create a simple widget that people can access from their websites - e.g by copy/past something like

<script language="javascript" src="test2.js"></script>
<div id="test"></div>

anywhere in their web pages. where is dynamically filled via Jquery and the functions in/on test2.js.

I can do it if JQuery is actually "printed" on the page of test2.js, but I cannot get any JQuery functions to work if I try to include/call JQuery dynamically. How do you call JQuery via javascript and then get it to work with the functions on the page?

And/Or is there an easy way to add the <div id="test"></div> dynamically aswell? Sure I can body.append etc. but that only adds at the bottom of the page. Is there a way to .append in the position where the script include

<script language="javascript" src="test2.js"></script>

is actually placed?

Hope I make sence.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about dynamic