jquery加载页面时触发事件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
    <!-- 引入jQuery -->
    <script src="jq.js"></script>
</head>
<body>
        <script>

            // 方式1:
            $(document).ready(function(){
                // 要执行的操作 ...
                console.log("OK")
            });

            // 方式2:
            $(function(){
                // 要执行的操作 ...
                console.log("OK2")
            });

        </script>
</body>
</html>

  

posted @ 2023-05-16 09:44  映辉  阅读(144)  评论(0)    收藏  举报