有没有办法在Jquery中调用函数'在文档准备好之前'? [英] Is there any way to call function 'before document ready' in Jquery?

查看:62
本文介绍了有没有办法在Jquery中调用函数'在文档准备好之前'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文档准备好之前调用函数,那么Jquery中是否有任何方法可以执行此操作?

I want to call function before document get ready, so is there any method in Jquery to do this?

推荐答案

如果你只需调用head标签中的一个函数,它会在DOM被解析之前立即执行(这就是 ready 解决的'问题')。

If you simply call a function in the head tag it will execute immediately, before the DOM is even parsed (that's the 'problem' that ready solves).

<!doctype html>
<html>
    <head>
        <script>alert(1)</script>
    </head>
    <body>
    </body>
</html>

这篇关于有没有办法在Jquery中调用函数'在文档准备好之前'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆