javascript - 获取具有特定类而不是特定样式的元素
问题描述
使用纯 JavaScript,如何获取所有没有 CSS 样式的元素?我需要获取未隐藏的表格行,并且它们没有附加明确的“显示”。
<table>
<tr class='form-row-links'>
Stuff...
</tr>
</table>
document.querySelectorAll('.form-row-links[style="display:is_not_none;"]') //pseudocode, of course :)
css 样式display=none
在页面初始化后应用到<tr>
元素。
解决方案
感谢@Ry- 将我指向getComputedStyle
我实际上认为我可以只声明该行的初始样式,然后它可能会被我的 JavaScript 用“none”或不覆盖:
<table>
<tr class='form-row-links' style='display:table-row;'>
Stuff...
</tr>
</table>
document.querySelectorAll('.form-row-links[style="display:table-row;"]')
推荐阅读
- angular - Angular Router 无法解析所需的参数
- reactjs - 使用 Reactjs 根据 Contestant ID 对齐和显示结果
- sql-server - 系统自动更新 SQL Server 全文索引导致阻塞和超时
- ruby-on-rails - 单表继承 - 附加类名
- ios - HealthKit:每日平均心率
- swift - Textview替换字符不起作用
- javascript - Firebase 消息 getToken() 无法解析
- git - 推送时出现Git错误(远程无法上报状态)
- javascript - 看不到循环的所有价值
- mysql - 安装mysql2 gem的问题