RicardO
RicardO

Reputation: 1229

is there a way to run a JQuery function even the DOMs are not yet loaded

im thinking if there is a way to run a jquery function like $.post even if the DOM's are not yet loaded..

Upvotes: 0

Views: 56

Answers (2)

JAL
JAL

Reputation: 21563

Yes, if you place your script after jQuery has been loaded, you are free to execute any jQuery functions. However, DOM manipulation will, of course, be unreliable if you're outside of a $(document).ready() block or similar.

Upvotes: 1

TomWilde
TomWilde

Reputation: 248

Yes you can, once jquery has loaded.

function checkJquery(){
    if(typeof($)==undefined){
        setTimeout(checkJquery,500);
    } else {
        start();
    }
}
setTimeout(checkJquery,500);

Then write your code in start().

Upvotes: 1

Related Questions