, , getComputedStyle
, , .
let style1 = window.getComputedStyle(document.getElementById('s1'));
let style2 = window.getComputedStyle(document.getElementById('s2'));
document.getElementById('i1').value = style1.getPropertyValue("background-color");
document.getElementById('i2').value = style2.getPropertyValue("background-color");
<div style='background-color: cyan'>
<span id='s1'>Span without backgound</span>
</div>
<div style='background-color: cyan'>
<span id='s2' style='background-color: yellow'>Span with backgound</span>
</div>
<input id='i1' type='text' />
<input id='i2' type='text' />
Hide result, getComputedStyle
W3Schools, , :
- , , "" .
, , "" , , , .