dmitry111,
Вариант ...)))
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
.xxx {
width: 50px;
height: 50px;
background: blue;
margin: 10px;
float: left;
}
.yyy {
width: 50px;
height: 50px;
background: red;
margin: 10px;
float: left;
}
</style>
<title></title>
</head>
<body>
<div class="xxx"></div>
<div class="xxx"></div>
<div class="xxx"></div>
<div class="xxx"></div>
<div class="xxx"></div>
<script>
document.onclick = function replaceClass () {
var elements = document.getElementsByClassName("xxx"),
i,
len;
for (i = elements.length-1; i > -1; i -= 1) {
elements[i].className = "yyy";
}
};
</script>
</body>
</html>