It depends on how much control you have over the original HTML.  If
you're generating it from a dynamic language like coldFusion, ASP,
PHP, etc. and you will always be linking a specific link with a
specific div AND you don't mind adding ID's the fastest selector is $
('#'+this.id.split("_")[1]);  You could go shorter by using a class -
it would be $('div.c1'); but the lookup is faster with ID's if only by
a few ms.

Otherwise, yours looks as short as safely possible.  While you can
pass an expression to parent(), I doubt $(this).parents("tr + tr
div"); would work, though I think it would as a straight css selector.

<TR>
  <TD>
     <A id="a_1" class="c1">ONE</A>
  </TD>
</TR>
<TR>
  <TD>
     <DIV id="div_1" class="c1">TWO</DIV>
  </TD>
</TR>

FWIW :)
On May 22, 4:52 pm, "Glen Lipka" <[EMAIL PROTECTED]> wrote:
> But your answer is much longer than
> $(this).parents("tr").next("tr").find("div")
>
> I'm not saying I want to bind the click or get the value of the DIV.  I just
> want to find it with a single selector.
> Actually I plan to slideDown() the Div using Toggle on the A.
>
> Glen
>
> On 5/22/07, Sean Catchpole <[EMAIL PROTECTED]> wrote:
>
>
>
> > I believe that might be the shortest way to get the element, however if
> > speed is your concern, then I suggest storing the divs before hand. Give
> > this code a try:
>
> > var div = $("tr td div");
> > $("tr td a").each(function(i){
> >   $(this).click(function(){
> >     alert(div[i].innerHTML);
> >     return false;
> >   });
> > });
>
> > ~Sean

Reply via email to