2
It’s a simple function, but it’s starting to turn into a monster, the only thing that changes is the number at the end of each word. Does anyone have any tips on how to shorten this code? No minifying Note: I don’t want to decrease the size in KB, but in lines.
function adc_atalho(qm){
if (qm == 1 ) {
document.getElementById("botaoAtalho1").style.display = "none";
document.getElementById("botao1").style.display = "inline";
document.getElementById("btRemover1").style.display = "inline";
}
else if (qm == 2) {
document.getElementById("botaoAtalho2").style.display = "none";
document.getElementById("botao2").style.display = "inline";
document.getElementById("btRemover2").style.display = "inline";
}
else if (qm == 3) {
document.getElementById("botaoAtalho3").style.display = "none";
document.getElementById("botao3").style.display = "inline";
document.getElementById("btRemover3").style.display = "inline";
}
else if (qm == 4) {
document.getElementById("botaoAtalho4").style.display = "none";
document.getElementById("botao4").style.display = "inline";
document.getElementById("btRemover4").style.display = "inline";
}
else if (qm == 5) {
document.getElementById("botaoAtalho5").style.display = "none";
document.getElementById("botao5").style.display = "inline";
document.getElementById("btRemover5").style.display = "inline";
}
else if (qm == 6) {
document.getElementById("botaoAtalho6").style.display = "none";
document.getElementById("botao6").style.display = "inline";
document.getElementById("btRemover6").style.display = "inline";
}
}
It depends on the context of the page, looking so it is kind of difficult to understand what it does, but I would advise to fit a vector there, it would be much simpler
– Lucas Finetti