[英]Is there any way to call function 'before document ready' in Jquery?
我想在文档准备好之前调用函数,所以Jquery中有什么方法可以做到这一点?
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). 如果仅在head标记中调用一个函数,它将在DOM解析之前立即执行(这是
ready
的“问题”)。
<!doctype html>
<html>
<head>
<script>alert(1)</script>
</head>
<body>
</body>
</html>
Just call your function before the document ready statement. 只需在文档ready语句之前调用您的函数即可。
<script>
thisWillFireImmediately();
$(function() {
thisWillFireOnDocumentReady();
});
</script>
If you are using .hide() or display: none; 如果使用.hide()或显示:none; - the hiding of the divs will be displayed.
-将显示div的隐藏。
try: 尝试:
visibility: hidden;
it worked for me after trying many other ways. 在尝试了许多其他方式后,它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.