Ahmad Alsanie Ahmad Alsanie - 1 year ago 81
Javascript Question

Loading your JavaScript after an external JS get executed

I've a problem that is a bit tricky over here, I'm trying to apply a simple JQuery line of code that

to a
class pop-up

but the problem is that class
is not accessible after

This class is actually added from an external
and the
is also added from an external
so I'm wondering

How To Add The Class using JQuery after the external JS get executed so pop_up class can be found using:


What I've tried:

jQuery(document).ready(function($) {

this is not working as the external
added the class somehow after
, so if you tried to print out
it will be undefined.

I've also tried to look for the class using a constant class container of
like this:


that didn't work either, I know for a fact the problem is with calling the function in
as some how the external
get executed after it so,

is there away around this?

if not, is there a way to detect if all of external JS files are ready and loaded?

Answer Source

You can have $(document).ready() multiple times in a page. The code gets run in the sequence in which it appears.

You can use the $(window).load() event for your code since this happens after the page is fully loaded and all the code in the various $(document).ready() handlers have finished running.

  //your code here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download