0
即時通訊嘗試通過一個按鈕,使用事件偵聽器更改多個對象的顯示屬性。它工作正常,如果我只是想改變一個對象的顯示在一次,但不是全部三個。通過一個按鈕更改多個對象的style.display JavaScript
任何想法?
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";
});