首页 > Web开发 > 详细

jQuery入口函数四种写法

时间:2020-01-23 14:12:00      阅读:104      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>04-jQuery入口函数的其它写法</title>
    <script src="js/jquery-1.12.4.js"></script>
    <script>
        // 1.第一种写法
        $(document).ready(function () {
            // alert("hello lnj");
        });

        // 2.第二种写法
        jQuery(document).ready(function () {
            // alert("hello lnj");
        });

        // 3.第三种写法(推荐)
        $(function () {
            // alert("hello lnj");
        });

        // 4.第四种写法
        jQuery(function () {
            alert("hello lnj");
        });
    </script>
</head>
<body>

</body>
</html>

在项目中以上的写法都可以使用,个人比较推荐用第三种写法,简洁方便

jQuery入口函数四种写法

原文:https://www.cnblogs.com/xdsuannai/p/12230562.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!