会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132358个问题
WEB前端全系列/第二阶段:JavaScript编程模块/面向对象编程 272楼
WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 273楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
          .div1{
            background-color: blue;
            width: 500px;
            height: 500px;
        }
        .div2{
            background-color:pink;
            width: 200px;
            height: 200px;
            margin: 150px;
        }
    </style>
</head>
<body>
    <div class="div1">这是div1
        <div class="div2">这是div2</div>
    </div>
    <button class="btn">删除</button>
    <script>
        var div1=document.querySelector('.div1');
        var div2=document.querySelector('.div2');
        var btn=document.querySelector('.btn');
        function fun1(){
            console.log('这是div1');
        }
        function fun3(){
            console.log('这是div1第二次');
        }
        function fun2(){
            console.log('这是div2');
        }
        div1.attachEvent('click',fun1);
        div2.attachEvent('click',fun2);
        div1.attachEvent('click',fun3);
    </script>
</body>
</html>

老师,他说不支持这个方法image.png

WEB前端全系列/第二阶段:JavaScript编程模块/浏览器模型(BOM) 274楼
WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 278楼
WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 279楼
WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 280楼
WEB前端全系列/第二阶段:JavaScript编程模块/运算符_数据类型和流程循环语句 281楼
WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 284楼
WEB前端全系列/第二阶段:JavaScript编程模块/运算符_数据类型和流程循环语句 285楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637