views:

56

answers:

1

Here is the piece of javascript that correctly identifies a UL element:

$(this.parentNode.nextSibling.nextSibling.children[0]);

The html it looks over is: (with 'this' referring to the .cs_previousArrow as the initial selector)

  <div id="cs_furlBar1">
      <p class="cs_furlHeaderClosed">INVESTOR SERVICES</p>
      <p class="cs_seeAllFurl"><a href="#">See all</a></p>
    </div>
    <div id="cs_investorServ" class="cs_hideOpen">
        <div class="cs_previousArrow"><img class="previous_btn" src="images/previousArrow.gif" width="11" height="21" alt=""></div>
      <div class="cs_vidThumbClip"></div>

in the div of cs_VidThumbClip, I use the load() action to insert a UL which has the class of cs_vidThumbList

So, the above javascript, after some bouts with Firebug, works but I'm thinking there must be a shorter (or better?) of selecting the same element.

The whole point of this is that I have 5 different divs each which will have its own content loaded to be scrolled so I wanted to avoid have the same code duped and then just the id changed.

Thanks

+1  A: 

You can try

$('ul.cs_vidThumbList', $(this).parent().parent())
fantactuka
Thanks, that worked. question.. what does the "," or comma do in the selector.. what does it distinguish?
Billy
@Billy, it's an optional second argument in the jQuery constructor, it allows you to add a context to the element. in this example, it's selecting the ul with a class of cs_vidThumbList from the $(this).parent().parent() object.
GSto
awesome, thanks!
Billy