爱编程的设计师 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日

悬赏问题

  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。