angular - 读取打字稿中的所有表头列名
问题描述
下面是我的表结构。我想阅读打字稿中的所有表格标签或标题列。
<table>
<tr>
<th>name</th>
<th>dob</th>
</tr>
</table>
实际上我的意图是读取所有表头(标签)并想像下面这样应用css类我不想硬编码
document.getElementById("name").className = "defaultSort";
document.getElementById("dob").className = "defaultSort";
请任何人都可以在这里提供帮助
解决方案
https://developer.mozilla.org/nl/docs/Web/API/Document/querySelector
document.querySelectorAll("#uniqueTableName th")
这将获取所有表头元素,对其进行循环以设置不同的类等。
推荐阅读
- javascript - 在 Mapbox GL 中具有全屏预览图像 onHover 属性以覆盖整个地图
- c# - 什么是即时检测asp网站中数据库更改的C#代码?
- android - Kotlin 当每个案例都有多个结果时
- neo4j - 无法运行具有两个加权关系的 node2vec 算法
- php - 如何使用 laravel 收银员在 Stripe 订阅上应用优惠券代码
- r - 使用 sf::st_crop() 和 raster::crop() 裁剪光栅堆栈时出错
- javascript - 为什么动画 MapBox 地图在 CPU 上尖叫?
- visual-studio-code - 使用 Visual Studio Code 运行 python 代码时出现“滚动条错误:空令牌”
- python - 根据标签在DataFrame中查找索引位置
- fzf - 如何指定 fzf --preview 应该只在当前目录中查找文件?