Tengo dos botones en una página HTML y trato de mostrarlos una vez que se presiona un botón, pero solo se muestra uno.
este es el html
<button onclick="testLeft()" class="item-description" id= "left-item-description">.</button> <button onclick="testRight()" class="item-description" id= "right-image-description">.</button>Este es el CSS
.item-description { display: none; box-sizing: border-box; position: fixed; z-index: 4; font-size: 35px; font-weight: 600; height: auto; top: 30%; padding: 10px 10px; color:white; background-color: transparent; border-radius: 4px; border: 3px solid black; transition: all 0.2s ease; } #left-item-description { margin-left: 10%; margin-right: 60%; } #right-image-description { margin-right: 10%; margin-left: 60%; }Y este es el javascript
function newGame(){ score = -1; increaseScore(); correct = true; for (let i = 0; i < used.length; i++){ used[i] = false; } indexLeft = shuffleIndex(); indexRight = shuffleIndex(); var left = document.getElementById("left-item-description"); var righ = document.getElementById("right-item-description"); left.style.display = "block"; left.innerText = items[indexLeft]; document.getElementById("left-item-image").src=images[indexLeft]; righ.style.display = "block"; righ.innerText = items[indexRight]; document.getElementById("right-item-image").src=images[indexRight]; }El botón izquierdo funciona perfectamente como quiero, pero por alguna razón, el botón derecho no se muestra
La identificación del elemento para su botón derecho es "descripción de la imagen correcta", pero en su Javascript está tratando de obtener "descripción del elemento correcto".
cambie el atributo id de este: var righ = document.getElementById("right-item-description"); to var righ = document.getElementById("right-image-description"); y debería funcionar.