how to make a background-color on a div tag

后端 未结 2 1161
礼貌的吻别
礼貌的吻别 2021-01-29 06:54

I have this code:

 
2条回答
  •  梦如初夏
    2021-01-29 07:32

    T.J. Crowder beat me to it, but just as a demo, if you were hellbent on using setAttribute, you could do so like this:

    document.getElementById("pic1").setAttribute("style","background-color:red");
    

    As you see, the css attribute is background-color, not the html attribute.

提交回复
热议问题