触发javascript中未定义的孩子的点击事件时

问题描述 投票:-1回答:1

我正在尝试模拟对话列表中的所有子节点的点击。当我执行这行代码document.querySelectorAll('[aria-label="Conversations list"]')[0].childNodes[0].childNodes[0].children[0].children[0].children[1]得到这个结果


     <div role="button" tabindex="-1" id="rx-vlv-1" aria-label="grop, group 
         chat, 3, 13:37, No new messages, " style="position: relative; display: flex; flex-direction: column; flex-grow: 0; 
    flex-shrink: 0; overflow: visible; align-items: stretch;
     cursor: pointer; height: 59px; transition: transform 0.4s ease 0s;"> 
     </div>

但是当我尝试预先形成点击未定义时。如果我错了,我是这项技术的新手帮助我

document.querySelectorAll('[aria-label="Conversations list"]')[0].childNodes[0].childNodes[0].children[0].children[0].children[1].click();

有什么建议 ??

提前致谢!!

javascript click
1个回答
0
投票

这是因为执行了点击,但that function总是返回undefined

© www.soinside.com 2019 - 2024. All rights reserved.