使用jQuery

<!--@description-->
<!--@author beyondx-->
<!--@date Created in 2022/07/31/ 19:02-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div></div>
    <script src="jquery-1.12.4.js"></script>
    <script>
        /**
         * 引入 入口函数的 必要性
         * 防止 页面element没有加载出来, 就执行 js代码
         * 并且后期 js代码, 放到 单独的文件中, 如果被 其他html页面, 引入到了 比较靠前的位置
         * 如果没有 入口函数, 就会出现 页面element 还没有加载完, 就执行了 js代码
         */
        $(document).ready(function () {
            $('div').width(100).height(100).css('backgroundColor', 'red').text('哈哈'); // 链式编程
        });
    </script>
</body>
</html>

posted on 2022-07-31 19:10  beyondx  阅读(7)  评论(0编辑  收藏  举报

导航