Just what is a jQuery collection that we pass along into jQuery? I
feel like I'm missing something to be able to use jQuery for my own
data.

On Feb 9, 8:43 am, cbmtrx <[EMAIL PROTECTED]> wrote:
> Thanks lihao.
>
> Actually, there are cases when there would be more than one "newdiv"
> following an "olddiv"...which means that the jquery .next identifier
> wouldn't always work. ie: It's not a 1:1 ratio. So I've been trying to
> find the most simple&elegant solution, without resorting to the old
> javascript functions...
>
> From what little I've learned so far, jquery seems to work mostly in
> one direction (JQ -> DOM) and it doesn't seem all that geared up for
> doing things the other way around (unless you use a plugin like
> metadata for passing vars, which isn't any simpler).
>
> Emlyn
>
> On Feb 8, 11:35 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > On Feb 8, 4:08 pm, cbmtrx <[EMAIL PROTECTED]> wrote:
>
> > > OK, I'll need to look into this click event. If it's worth rewriting
> > > (because the original degrades poorly) then I'll probably do it this
> > > way.
>
> > > Was hoping jquery would simplify!! :/
>
> > For your sample code, you don't need that javascript link, you can
> > just define 'click(toggle)' event for <a /> element and then trigger
> > it in <input /> elememt's 'click' event. using 'class' instead of 'id'
> > and letting jQuery help you find corresponding DIVs can make your code
> > simpler (you can extend this into more than 2 groups easily):
>
> > <!--ONE-->
> > <a href="#">Open 1</a>
>
> > <div class="olddiv">
> >   Default page content
> > </div>
>
> > <div class="newdiv">
> >   <form>
> >     New page content
> >     <input type="button" value="Close" />
> >   </form>
> > </div>
>
> > <!--TWO-->
> > <a href="#">Open 2</a>
>
> > <div class="olddiv">
> >   Default page content
> > </div>
>
> > <div class="newdiv">
> >   <form>
> >     New page content
> >     <input type="button" value="Close" />
> >   </form>
> > </div>
>
> > <script type="text/javascript">
> >  $('a').toggle(function() {
> >      $(this).next('div.olddiv').hide()
> >             .next('div.newdiv').show();
> >  }, function() {
> >      $(this).next('div.olddiv').show()
> >             .next('div.newdiv').hide();
> >  });
> >  $('[EMAIL PROTECTED]"Close"]').click(function() {
> >      $(this).parents('div.newdiv').prevAll('a:first').click();
> >  });
> > </script>
>
> > Regards,
> > lihao(XC)

Reply via email to