<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />
<style type='text/css'>
.img1 {
font-style: italic;
}
.img2 {
color: red;
}
</style>
</head>
<body>
<div class="img" id="img">
<div id="img1" class="img2">1</div>
<div id="img2" class="img1">2</div>
<div id="img3" class="img1">3</div>
<div id="img4" class="img1">4</div>
<div id="img5" class="img1">5</div>
</div>
<div class="button">
<div class="klor klor1">red</div>
<div class="klor klor2">blue</div>
<div class="klor klor3">green</div>
<div class="klor klor3">yellow</div>
<div class="klor klor3">gold</div>
</div>
<script>
var block = document.querySelectorAll('.img div'),
btn = document.querySelectorAll('.button .klor'),
index = null;
btn.forEach((el,i)=>{
if(block[i].classList.contains('img2')) index = i;
el.addEventListener('click', function(e){
block[i].className = 'img2';
if(index != i && index != null){
block[index].className = 'img1';
}
index = i;
});
});
</script>
</body>
</html>
так?