That works great. Thanks!

On May 14, 3:01 pm, Bryan <stern....@gmail.com> wrote:
> Try this
>
> var ans = $("#carousel li a.active").parent().attr("carouselindex");
>
> Cheers,
> Bryan
>
> On May 14, 2:49 pm, "Matt M." <quink...@gmail.com> wrote:
>
> > Hello,
>
> > I have been learning jQuery and have been loving it so far. But can't
> > figure out how to do the following...
>
> > 1) Find the <a> inside a <ul> that has an active class.
> > 2) Grab the value from the parent <li> and put it into a variable to
> > be used elsewhere.
>
> > Here is the example markup...
>
> > <ul id="carousel">
> >     <li class="carousel-item" carouselindex="1">
> >      <a href="/someurl"><img src="/someimg" alt="" /></a>
> >    </li>
> >    <li class="carousel-item" carouselindex="2">
> >      <a class="active" href="/someurl"><img src="/someimg" alt="" /></
> > a>
> >    </li>
> > </ul>
>
> > So, in this example, I'd like to return a variable that = 2.
>
> > Any help is appreciated. Thanks!

Reply via email to