一键更改style.display多个对象JAVASCRIPT

Change style.display on multiple objects through one button JAVASCRIPT

我正在尝试使用事件侦听器通过一个按钮更改多个对象的显示属性。如果我只想一次更改一个对象的显示而不是所有三个对象的显示,它工作正常..

有什么想法吗?

http://jsfiddle.net/rn9vrwyg/

var ruta1 = document.getElementById('ruta1')
var ruta2 = document.getElementById('ruta2')
var ruta3 = document.getElementById('ruta3')

document.getElementById('knapp1').addEventListener("click", function(){
ruta1.style.display = "block";
ruta2.style.display = "none";
ruta3.style.display = "none";

});

document.getElementById('knapp2').addEventListener("click", function(){
ruta2.style.display = "block";  
ruta1.style.display = "none";
ruta3.style.display = "none";

});

document.getElementById('knapp3').addEventListener("click", function(){
ruta3.style.display = "block";
ruta1.style.display = "none";
ruta2.style.display = "none";


});
<div id="ruta1">
      <p>Informationbox #1</p>
    </div>
        <div id="ruta2">
      <p>Informationbox #2</p>
    </div>
        <div id="ruta3">
      <p>Informationbox #3</p>
    </div>

这些 div 和 p 标签没有正确关闭。关闭这些标签,然后它会按预期工作。