1
I am developing an interactive infographic in which the person will have to go clicking on certain buttons to open the content related to this button, so far so good, but I wanted the person to press in a certain order, for example the button in section 2 only if it activated after she clicked the button in section 1 and so on, I don’t want to hide the buttons I want to make them visible and deactivate them until the person clicks on the button in the previous section. I’ll put an example of the code.
function aparecer(el) {
var display = document.getElementById(el).style.display;
if(display == "none"){
document.getElementById(el).style.display = 'block';
console.log('funcionou');
}else{
console.log('não funcionou');
}
}
<a href="#secao1"><img src="img.png" class="img-fluid" onclick="aparecer('secao1')"></a>
<a href="#secao2"><img src="img.png" class="img-fluid" onclick="aparecer('secao2')"></a>
<a href="#secao3"><img src="img.png" class="img-fluid" onclick="aparecer('secao3')"></a>
<div id="secao1" style="display: none;">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere atque quisquam doloremque tempora dolorum facilis ea molestiae dolorem iure tempore, eos architecto eum aliquam quas officia quae natus animi provident.</p>
</div>
<div id="secao2" style="display: none;">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium, impedit dolorem soluta perferendis doloribus, odit vel vero iste itaque eos praesentium. Quisquam enim, aliquid harum eius vel a fugit rem?</p>
</div>
<div id="secao3" style="display: none;">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero cumque ipsum impedit sed, accusantium dolorem modi quae iusto. Deserunt excepturi eaque mollitia voluptas fugiat accusantium assumenda aut perspiciatis libero provident. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Dolores natus corrupti, sed velit iusto laborum obcaecati cumque dolore odit, tenetur, ullam commodi nam. Officiis omnis veritatis voluptatum ex aut in!</p>
</div>
Only one point the buttons already have to start idle so put the variable x with the first x[1]. disabled = true; x[2]. disabled = true; before if outside function
– FireWallSP