ниже пример использования getElementsByClassName
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>test</title>
<style>
.kar {
border: 1px solid;
margin: 1em;
}
</style>
</head>
<body>
<button class="btn1">Изменить ширину</button>
<div class="kar">Hello World</div>
<div class="kar">Hello World</div>
<div class="kar">Hello World</div>
<div class="kar">Hello World</div>
<script>
var btn = document.getElementsByClassName('btn1')[0];
btn.onclick = function () {
var kar = document.getElementsByClassName('kar');
for (var i = 0; i < kar.length; i += 1) {
kar[i].style.width = "25%";
}
}
</script>
</body>
</html>