我想计算 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
。然后您可以将计数值附加到任何您想要的地方。
但这只是你解决它的想法...不是最好的方法...
祝你好运
关于javascript - 计算 html 表中的唯一值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50038701/