Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get computed background color style inherited from parent element

Tags:

I have this HTML page:

document.addEventListener("DOMContentLoaded", function (event) {
  var inner_div = document.getElementById("innerDiv");
  console.log(getComputedStyle(inner_div, null)["backgroundColor"]);
});
#outterDiv {
  background-color: papayawhip;
}
<div id="outterDiv">
  <div id="innerDiv">
    I am an inner div
  </div>
</div>

I want to find out the computed background color of the inner div without having to look into parent(s) element's computed style. Is that possible?