我正在尝试更改那些innerHTML值与我的数组匹配的单元格背景颜色。我该怎么做?
var numbers = ["15628","15623","15656","11628"];
var table = document.querySelector("[name='main']")
.contentWindow.document.getElementById("music").rows.length;
for (i = 4; i < table -1; i++){
if (document.querySelector("[name='main']")
.contentWindow.document.getElementById("music").rows[i].cells[1].innerHTML == numbers)
{
document.querySelector("[name='main']")
.contentWindow.document.getElementById("music")
.rows[i].cells[1].style.backgroundColor = "yellow";
};
答案 0 :(得分:0)
您确定此元素选择正确吗:document.querySelector(“ [name ='main']”)。contentWindow.document.getElementById(“ music”)。rows [i] .cells [1]吗? 不看HTML很难分析。 如果可以,则可能需要这样的解决方案:
library(dplyr)
library(tidyr)
df <- data.frame(var = c(1,2,3,0,7,8,0,0,9,8,9,0,0,0,4,7,2,4))
df <- df %>%
dplyr::mutate(var = ifelse(var == 0, NA, var)) %>%
tidyr::fill(var, .direction = c("down"))
df