Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
olá, escrevi um script alternando entre 4 divs, porem o script ficou muito grande e repetitivo.De que forma posso resumir o script:
function bgcolor(id) {
if(id == 1){
document.getElementById('id1').style.textDecoration = "underline";
document.getElementById('id2').style.textDecoration = "none";
document.getElementById('id3').style.textDecoration = "none";
document.getElementById('id4').style.textDecoration = "none";
}else if (id ==2){
document.getElementById('id1').style.textDecoration = "none";
document.getElementById('id2').style.textDecoration = "underline";
document.getElementById('id3').style.textDecoration = "none";
document.getElementById('id4').style.textDecoration = "none";
}else if (id ==3){
document.getElementById('id1').style.textDecoration = "none";
document.getElementById('id2').style.textDecoration = "none";
document.getElementById('id3').style.textDecoration = "underline";
document.getElementById('id4').style.textDecoration = "none";
}else if (id==4){
document.getElementById('id1').style.textDecoration = "none";
document.getElementById('id2').style.textDecoration = "none";
document.getElementById('id3').style.textDecoration = "none";
document.getElementById('id4').style.textDecoration = "underline";
}
}Carregando comentários...