If you want to simplify it, I think you could agroup the tags and add the
properties, for example.

$('#normal').click(function(){
   $('#bereit').ScrollTo(800);

   // toggleClass
   $('#normal dd,#label_radiobutton_1').toggleClass('ausgewaehlt');

   // removeClass
   $('#standard dd,#profi
dd,#label_radiobutton_2,#label_radiobutton_3').removeClass('ausgewaehlt');

   //checked
   $('#radiobutton_1').attr('checked','checked');
   $('#radiobutton_2,#radiobutton_3').attr('checked','');
});


But I would suggest you to relook at you HTML/DOM so you can try a better
and abstract way to toggle, remove and check all your elements. If you show
us an url explainning what do you want, I could try to help you a little
more.

Cheers.




On 2/12/07, Dominik Hahn <[EMAIL PROTECTED]> wrote:

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
[email protected]
http://jquery.com/discuss/




--
Joan Piedra || Frontend webdeveloper
http://joanpiedra.com/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to