Reputation: 15925
I have the following which dynamically adds javascript and or jquery scripts to my page as and when needed:
var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = url;
$("#someElement").append( script );
Is it possible to remove one of more of the scripts which have been added dynamically? i.e. if $("#someElement")
is .remove
ed, will that also remove the script within it?
Upvotes: 1
Views: 531
Reputation: 206
Please see the first awnser here, couldnt explain it much better myself; Best way to load and unload JS file via JQuery
Basically, you cant, but you can work around that by unloading specifics (remove events, clear vars, etc) See the link for more info.
Upvotes: 1