If I have a if/else statement:
if(a) {
$('#aa').removeClass('Offselect').addClass('Onselect').css('background-image','url(../images/menu.gif)');
}
else if(b) {
$('#bb').removeClass('Offselect').addClass('Onselect').css('background-image','url(../images/menu.gif)');
}
else if(c) {
$('#cc').removeClass('Offselect').addClass('Onselect').css('background-image','url(../images/menu.gif)');
}
else if(d) {
//same part
}
You can see the code have the same part:
removeClass('Offselect').addClass('Onselect').css('background-image','url(../images/menu.gif)');
Is it possible or any suggestion to shorten the same code?
Aucun commentaire:
Enregistrer un commentaire