我有一张桌子和班级的桌子。在该表中是包含许多tr主体。在tr中是td class=status,它显示"UP“文本。我需要进入每个tr并检查td class=status是否启动。如果没有打开,那么我需要隐藏该tr。HTML就在这张图片上。
有什么想法吗?
发布于 2018-06-11 03:14:06
首先从表中获取tr
列表,并将其转换为数组:
[...document.querySelector('table').querySelectorAll('tr')]
// then forEach over the array to conditionally hide the row
.forEach(tr => {
// select the element with class 'status' check if txt is not UP
const el = tr.querySelector('.status');
if (!el || el.textContent.trim() !== 'UP') {
tr.style.display = 'none'; // hide tr
}
});
https://stackoverflow.com/questions/50787111
复制相似问题