爱编程的设计师 2022-05-23 22:16 采纳率: 94.4%
浏览 32
已结题

获取DOM的时候 为什么打印出的结果一样,却没有相同的方法和属性(例如element.style)

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
运行结果及报错内容
<!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>
        .main{
           margin: 100px auto;
           width: 300px;
           height: 200px;
           background-color: rgb(168, 168, 168);
           overflow: hidden;
           text-align: center;
        }
       .father{
           display: inline-block;
           margin: 90px auto;
       }
       .father>button,.father>i{
           float: left;
           margin-left: 15px;
           width: 35px;
           height: 25px;
           background-color: rgb(36, 36, 36);
           color: aliceblue;
           font-style: normal;
       }
       .father .one{
           margin-left: 0px;
       }
      
    </style>
</head>

<body>
    <div class="main">
        <div class="father">
            <button class="one">+</button>
            <i>0</i>
            <button class="two">-</button>
        </div>
    </div>

    <script>
        var one = document.querySelector('.one');
        var one_one = document.getElementsByClassName('.one');
        var father = document.querySelector('.father');
        var son = father.querySelectorAll('button');
        console.log(son[0]);
        console.log(one);
    </script>
</body>

</html>

我的解答思路和尝试过的方法
我想要达到的结果

img

  • 写回答

1条回答 默认 最新

  • iMingzhen 2022-05-24 00:31
    关注

    请用console.dir(son[0])的方式来打印,具体查阅文档~

    如有帮助请采纳回答~

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 6月3日
  • 已采纳回答 5月26日
  • 修改了问题 5月23日
  • 创建了问题 5月23日

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改