[jQuery] how to simplify this
Hello,
I am looking for a way to simplify this chunk of code:
$('li#normal').click(function() {
$('#bereit').ScrollTo(800);
$('li#normal dd').toggleClass('ausgewaehlt');
$('li#standard dd').removeClass('ausgewaehlt');
$('li#profi dd').removeClass('ausgewaehlt');
$('label#label_radiobutton_1').toggleClass('ausgewaehlt');
$('label#label_radiobutton_2').removeClass('ausgewaehlt');
$('label#label_radiobutton_3').removeClass('ausgewaehlt');
$('input#radiobutton_1').attr('checked','checked');
$('input#radiobutton_2').attr('checked','');
$('input#radiobutton_3').attr('checked','');
});
$('li#standard').click(function() {
$('#bereit').ScrollTo(800);
$('li#normal dd').removeClass('ausgewaehlt');
$('li#standard dd').toggleClass('ausgewaehlt');
$('li#profi dd').removeClass('ausgewaehlt');
$('label#label_radiobutton_1').removeClass('ausgewaehlt');
$('label#label_radiobutton_2').toggleClass('ausgewaehlt');
$('label#label_radiobutton_3').removeClass('ausgewaehlt');
$('input#radiobutton_1').attr('checked','');
$('input#radiobutton_2').attr('checked','checked');
$('input#radiobutton_3').attr('checked','');
});
$('li#profi').click(function() {
$('#bereit').ScrollTo(800);
$('li#normal dd').removeClass('ausgewaehlt');
$('li#standard dd').removeClass('ausgewaehlt');
$('li#profi dd').toggleClass('ausgewaehlt');
$('label#label_radiobutton_1').removeClass('ausgewaehlt');
$('label#label_radiobutton_2').removeClass('ausgewaehlt');
$('label#label_radiobutton_3').toggleClass('ausgewaehlt');
$('input#radiobutton_1').attr('checked','');
$('input#radiobutton_2').attr('checked','');
$('input#radiobutton_3').attr('checked','checked');
});
It controls a list, when you click on one of the three items, it scrolls down to a online form (first line), the item is highlighted (first three lines), one of three radioboxes is checked (line 6-8) and the label for the checked radiobox is also highlighted (last three lines).
Can you help me?
Thanks,
Dominik
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/