Difference between body.style.backgroundColor and window.getComputedStyle(body).getPropertyValue('background-color')

后端 未结 4 1270
青春惊慌失措
青春惊慌失措 2020-12-20 02:11

I am trying to get the background color of the body, and I am wondering what is the difference between:

body.style.backgrounColor and

wi         


        
4条回答
  •  [愿得一人]
    2020-12-20 02:15

    just using body.style.backgroundColor will only be able to sense if an inline style is on the body and give you that (e.g. a style applied via the style attribute in the html or using the style property in JavaScript). getComputedStyle also gets styles that were applied to it via stylesheets in )

提交回复
热议问题