javascript - Loading js file into div using jquery -


i have js file , execute :

<div id="result">     <script type="text/javascript" src="js/tracking.js"></script> </div> 

my main page has 2 divs (2 colums in page) , there buttons on left div. when click first button, execute js file , display on right. can handle html files :

$("#result").load( "test.html" ); 

but js files think need use getscript. gave shot :

$("#result").load("#result",function(){$.getscript("js/tracking.js"); }); 

ok, executes script not loading "result" div. opens new page , displays result.

how should modify?

as far can understand, want load, execute & display js file.

check [demo][1]

  [1]: http://codepen.io/anon/pen/wryqlx 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -