<body id="bgcol">
<button id="colour1" class="colours" data-color="black" >Чёрный</button>
<button id="colour2" class="colours" data-color="#D8D8D8">Белый</button>
</body>
var colourDiv = document.getElementById("bgcol");
var colours = document.getElementsByClassName('colours');
for(var i=0; i< colours.length; i++) {
colours[i].addEventListener('click', function() {
var color = this.getAttribute('data-color');
colourDiv.style.backgroundColor = color;
}); }