thx.
But I've come up with a new wrapper set method to accomplish the goal.

$.fn.relation=function(handler) {
        $.each(this[0], function(key,val) {
                handler(key,val);
        });
};
$({a:1,b:2}).relation(function(n1,n2) {
        alert(n1+": "+n2);
});

On Sep 11, 4:55 am, Ariel Flesler <[EMAIL PROTECTED]> wrote:
> Or use DOM traversal (f.e using css classes).
>
> --
> Ariel Fleslerhttp://flesler.blogspot.com/
>
> On Sep 10, 8:57 am, 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