我想在文档准备好之前调用函数,所以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).
<!doctype html>
<html>
<head>
<script>alert(1)</script>
</head>
<body>
</body>
</html>
Just call your function before the document ready statement.
<script>
thisWillFireImmediately();
$(function() {
thisWillFireOnDocumentReady();
});
</script>
If you are using .hide() or display: none; - the hiding of the divs will be displayed.
try:
visibility: hidden;
it worked for me after trying many other ways.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.