<body>
<div id="first">
Первый элемент.
</div>
<div id="second">
Второй элемент.
</div>
<script>
var firstDiv = document.getElementById("first");
var secondDiv = document.getElementById("second");
secondDiv.style.backgroundColor = "gray";
firstDiv.style = secondDiv.style.cssText;
</script>
</body>