1

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!

1 Answer 1

3

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*/
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.