views:

554

answers:

1

I'm building a page that has a few divs of content that will slide in and out - just a few lines of code with jQuery Cycle.

I have a navigation on the side in which I want to append the links to. No problem with Jquery cycle - I can even specify an image or H3 tag that I want to use.

However, I want to append an entire div from the slide to show up in the sidebar. How would I go about selecting this div?

Right now my code is:

    $('#servicesWrap').cycle({
    fx: 'scrollLeft',
    speed:  'normal', 
    timeout: 0, 
    pager:  '#servicesSidebar',
    pagerAnchorBuilder: function(idx, slide) { 
    return '<li><a href="#">' + jQuery(slide).children(".serviceButton").eq(0).text() + '</a></li>';

} 

    });

I found the PagerAnchorBuilder on another stackoverflow post. It works great but It only grabs the text inside the div. I want to grab the entire div that looks something like this:

    <div class="serviceButton">
   ... Text and images go here...
    </div>

I'm sure this is simple, I just dont know jQuery good enough to select the entire div.

A: 

Try the following:

 return '<li><a href="#">' + $(slide).children(".serviceButton:first")[0].outerHtml + '</a></li>';
SLaks
That still returns text, but if I put another div within 'serviceButton' it grabs it..
Wes
I just changed that.
SLaks
Perfect! Thanks :)
Wes