Home  >  Q&A  >  body text

innerHTML问题?求大神解释?

 var a=document.getElementById("con");
 a.style.color="red";
 a.style.backgroundColor="#ccc"

请问为什么这里

var a=document.getElementById("con").innerHTML;

不能实现改变颜色和背景颜色呢??

看透不说透看透不说透2860 days ago1020

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:09:11

    InnerHTML problem? Can someone explain it? -PHP Chinese website Q&A-innerHTML problem? Can you please explain it? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 迷茫

    迷茫2016-12-20 13:45:14

    第二个获取的是id为con的标签里的内容,而背景色和颜色是标签的属性,不是标签里的内容的属性

    reply
    1
  • Cancelreply