麻烦老师检查,谢谢

来源:3-4 自由编程

qq_慕移动3101913

2020-03-23 17:08:42

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>属性操作</title>
    <style>
        .box{
            width: 500px;
            height: 500px;
            background-color: pink;
        }
        .text{
            width: 100px;
            height: 100px;
            background-color: blue;
        }
    </style>
</head>
<body>
    <p id="btn">点击这里!</p>
    <div id="box" class="box"> </div>

    <script src="https://cdn.bootcss.com/zepto/1.1.7/zepto.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            var $cr = $("<div class='text'>我是smallbox内容</div>");

            // 插入操作
            $('#btn').on('click' , function () {
                $("#box").append($cr);
                $(".text").attr("class","text");
                
                $('.text').on('click' , function () {
                    alert('已执行');
                  })
            });
        })

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


写回答

1回答

好帮手慕糖

2020-03-23

同学你好,代码是正确的,继续加油。祝学习愉快~

0

0 学习 · 6815 问题

查看课程