$("div :last-child");

(or this wacky way I tried before I learned CSS selectors....
$("div").children()[$("div").children().size() - 1])...)

Nic Luciano
http://www.twitter.com/nicluciano
http://www.linkedin.com/in/nicluciano


On Wed, Feb 11, 2009 at 9:49 PM, Risingfish <risingf...@gmail.com> wrote:

>
> Hi James, apologize for not being more precise. I'm using the input
> element as my base reference. So using that input element, I want to
> get the last sibling under the div. You are correct that if the span
> is not then the input is what I want. I may need to add more tags
> later (I'm sure you know hoe the development process goes when
> customers are involved. :) ), so a reliable way to get the last tag
> would be nice. Thanks!
>
> On Feb 11, 7:21 pm, James <james.gp....@gmail.com> wrote:
> > When you say "last sibling in a parent", what does that mean? Which
> > element is your base reference?
> >
> > In your example:
> > <div>
> >   <input ...... />
> >   <span>...</span>
> > </div>
> >
> > Do you mean your <div> is the base reference, and you want to find the
> > last child (thus, <span>) relative to that?
> > And if <span> is not there, you want <input>?
> >
> > On Feb 11, 4:12 pm, Risingfish <risingf...@gmail.com> wrote:
> >
> > > Before I accidentally hit enter, this is what I was trying to type: :)
> >
> > > <div>
> > >   <input ...... />
> > >   <span>...</span>
> > > </div>
> >
> > > The span might or might not be there, so I would like to just get the
> > > last sibling in a parent.
> >
> > > Thanks!
>

Reply via email to