<div style="width: 50px;height: 50px;background-color: red;"></div><br> <div style="width: 50px;height: 50px;background-color: red;"></div><br> <div style="width: 50px;height: 50px;background-color: red;"></div><br> <div style="width: 50px;height: 50px;background-color: red;"></div> <script> var divs = document.getElementsByTagName('div'); //console.log(divs); for(var i=0;i<divs.length;i++){ divs[i].onclick = function(){ this.style.width = '100px'; this.style.height = '100px'; } } </script>