[jQuery] Get attribute of the parent element into a variable

[jQuery] Get attribute of the parent element into a variable


Hi, All. Kind of new to jQuery, but having fun with it. Would like to
learn how to do the following...
1) Target the active <a>.
2) Find the parent <li>.
3) Grab the value of the attribute "jcarouselindex" and put it in a
variable to be used elsewhere.
Sample code below...
<ul id="carousel">
<li class="carousel-item" jcarouselindex="1">
<a href="/someurl"><img src="someimage.jpg" alt="" />
</li>
<li class="carousel-item" jcarouselindex="1">
<a class="active" href="/someurl"><img src="someimage.jpg" alt="" /