wow, i forgot about the $.each.
It's really nifty. thx a lot.

On Sep 10, 11:57 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> Give this a try:
>
> $.each({
> "#button1": "#menu1",
> "#button2": "#menu2,#menu3"
> "#button3, #button4": "#menu4,#menu5"}, function(button, menu) {
>
>   $(button).toggleClass("clicked");
>   $(menu).slideToggle("slow");
>
> });
>
> No need to add any features to jQuery.
>
> Jörn
>
> On Wed, Sep 10, 2008 at 1:57 PM, Galen <[EMAIL PROTECTED]> wrote:
>
> > Sometimes we need to build relaitons between two sets of elements. For
> > example, a bunch of buttons will cause a bunch of menus to slide. In
> > such case, we will have to register event listener for each of them.
> > what if we can write the code like this:
>
> > $({
> > "#button1": "#menu1",
> > "#button2": "#menu2,#menu3"
> > "#button3, #button4": "#menu4,#menu5"
> > }.click(function(slave) {
> >    var button=this;
> >    var menu=slave;
> >    button.toggleClass("clicked");
> >    menu.slideToggle("slow");
> > });
>
> > with the single statement executed, we have the relations between the
> > buttons and the menus as follow:
>
> > button1 will cause menu1 to slide.
> > button2 will cause menu2 and menu3 to slide at the same time.
> > both buttton3 and button4 will cause menu4 and menu5 to slide at the
> > same time.
>
> > There may be some potential problems, though.
> > i don't know how to call the returned wrapped set, and i'll call it
> > the "relative wrapped set" for the moment. Hope u don't mind.
> > So, do u think it is possible to write code like this?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to