Reputation: 8104
I want to be able to include an external jQuery script only after a certain jQuery event, for example, after fade in, like this:
<script type="text/javascript">
$(window).load(function() {
$('body').fadeIn(300, function() {
// Include http://www.mydomain.com/js/myscript.js
});
});
</script>
Is something like that possible? Or, if not, perhaps there's a way to activate a script that has already been included, but kept "dormant"?
I would appreciate help from an expert!
Upvotes: 1
Views: 86
Reputation: 171669
jQuery has an AJAX method $.getScript
http://api.jquery.com/jQuery.getScript/
$.getScript('http://www.mydomain.com/js/myscript.js',function(){
/* new script has already run, can call additional code here if needed*/
})
Upvotes: 3