How do I write a RGB color value in JavaScript?

前端 未结 6 1565
不知归路
不知归路 2020-12-28 13:09

I am trying to change the color of the function swapFE() below and I can\'t figure out how to write it. I was told to change the color of the phrase node to the color value

6条回答
  •  猫巷女王i
    2020-12-28 13:24

    dec2hex = function (d) {
      if (d > 15)
        { return d.toString(16) } else
        { return "0" + d.toString(16) }
    }
    rgb = function (r, g, b) { return "#" + dec2hex(r) + dec2hex(g) + dec2hex(b) };
    

    and:

    parent.childNodes[1].style.color = rgb(155, 102, 102);
    

提交回复
热议问题