I would like to know a possibility of an algorithm for me to select a DOM in a more dynamic way, without having to use getElementById
all the time.
I'd like to select all elements and manipulate in JS. Can someone help me with this, please?
<section id="step00" class="slide">
</section>
<section id="step01" class="slide">
</section>
Actually, I'm trying to display and hide the steps with each click. Type Step By Step.
Imagine I have to do all this:
const step00 = document.getElementById('step00')
const step01 = document.getElementById('step01')
const step02 = document.getElementById('step02')
const step03 = document.getElementById('step03')
const step04 = document.getElementById('step04')
const step05 = document.getElementById('step05')
const step06 = document.getElementById('step06')
const step07 = document.getElementById('step07')
const step08 = document.getElementById('step08')
const step09 = document.getElementById('step09')
const step10 = document.getElementById('step10')
const endTutorial = document.getElementById('endTutorial')
function initTutorial() {
showStep00()
}
function showStep00() {
console.log('Inicio o passo 0')
step00.removeAttribute('hidden')
step01.setAttribute('hidden', 'true')
}
function showStep01() {
console.log('Inicio o passo 1')
step00.setAttribute('hidden', 'true')
step01.removeAttribute('hidden')
}
There must be something more dynamic, where when I click a button with onclick="step03"
, for example, all other buttons are hidden.