javascript - 计算html表中的唯一值
问题描述
我想计算 html 表中的唯一值。(RGB 颜色)
我正在使用第三方网站,它使用 PHP 在表中写入值。我无权访问 PHP 脚本。
PHP 在这里写“{colorcode}”一个我定义的 rgb-to-hex。我有 5 个十六进制值:
火:#FF8C00
医疗帮助:#FD0202
危险材料:#19070B
其他:#4876FF
技术援助:#0000FF
我的目标是,我可以单独计算每种颜色并将其写在另一个表中。
这是我的网站,其中显示了表格:https
://www.feuerwehr-forstern.de/einsaetze/
我想计算的表格。
<table>
<tr style="font-size:16px; background-color:#670200; color:#FFFFFF;">
<th><b>Nr.</b></th>
<th><b>Missionstart</b></th>
<th><b>Title</b></th>
<th><b>Kind of mission</b></th>
<th><b>Place</b></th>
<th></th>
</tr>{liststart}
<tr>
<td style="color:#FFFFFF;" bgcolor={colorcode}><b>{missionnr}</b></td>
<td>{startdate} {starttime}</td>
<td>{missiontitle}</td>
<td>{kind of mission}</td>
<td>{missionplace}</td>
<td><u>{linkreport}</u></td>
</tr>{listend}
</table>
其他表,我想在“:”之后写下计数结果。
<table>
<tr style="font-size:16px; color:#FFFFFF;">
<th style="background-color:#FF8C00;"><b>fire:</b></th>
<th style="background-color:#FD0202;"><b>medical help:</b></th>
<th style="background-color:#19070B;"><b>hazardous materials:</b></th>
<th style="background-color:#4876FF;"><b>other:</b></th>
<th style="background-color:#0000FF;"><b>technical assistance:</b></th>
</tr>
</table>
解决方案
你可以试试这个:var blue_count = $('[bgcolor=#0000FF]').length
获取属性值为的td
元素的计数。然后你可以在任何你想要的地方附加计数值。bgcolor
#0000FF
但这只是你解决它的想法......不是最好的方法......
祝你好运
推荐阅读
- mongodb - 变量查询的索引策略是什么?
- r - ESS(Emacs):R调试下不要更改窗口配置(tracebug)
- ios - 带有图像和文本的 SwiftUI 表单选择器
- automated-tests - 空手道 - 身份验证 - 无法在密码下访问 url 地址
- python - SGDRegressor() 不断提高验证性能
- python - 为什么将一大块音频信号(PCM 16 位短阵列)乘以常数会产生机器人输出?
- javascript - 获得 LC 没有在字面上定义
- javascript - 在 p5js 草图中创建对象时出现语法错误
- azure - 用于在一个脚本中删除所有容器中 30 天以上的 .bak 文件的 Powershell 脚本
- c# - 在 Unity 中创建地形上的线栅格