开发者

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

开发者 https://www.devze.com 2023-01-27 08:04 出处:网络
im thinking if there is a way to ru开发者_开发问答n a jquery function like $.post even if the DOM\'s are not yet loaded..Yes, if you place your script after jQuery has been loaded, you are free to exe

im thinking if there is a way to ru开发者_开发问答n a jquery function like $.post even if the DOM's are not yet loaded..


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.


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().

0

精彩评论

暂无评论...
验证码 换一张
取 消