<div id="name">1</div>
<div id="name">2</div>
<div id="name">3</div>
<div id="name">4</div>
<div id="name">5</div>
<button id = 'but'>Click me</button>
<script type="text/javascript">
var but = document.getElementById('but');
var elem = document.querySelectorAll('[id="name"]');
//убирает элемент <div id= 'name'></div>
var hid = function() {
for(var i = 0; elem[ i ]; i++ ) {
elem[ i ].style.display = 'none';
}
}
but.addEventListener('click',hid,false);
</script>