【发布时间】:2016-10-10 03:01:18
【问题描述】:
我正在尝试玩我不久前创建的 Facebook 群聊。显而易见的事实是我添加了太多人,我需要绝对删除每个人。 这是其中一个按钮的 html(它们都共享同一个类):
<a class="_42ft _4jy0 _4jy3 _517h _51sy" role="button" href="#" ajaxify="/chat/remove_participants/?elem_id=u_32_4&uid=1124361845&tid=958151054268315" rel="async-post">Remove</a>
因此,我希望在这里使用它,它会一次单击所有按钮:
document.getElementById('_42ft _4jy0 _4jy3 _517h _51sy').click();
但是错误信息...:
VM1719:1 Uncaught TypeError: Cannot read property 'click' of null(…)
出现了..我真的很困惑为什么点击功能不起作用。
干杯
【问题讨论】:
-
Id != 类。要按班级选择,您需要
document.getElementsByClassName('theClassName'); -
不要刮脸书。使用 API。
标签: javascript facebook google-chrome console