Question: I have a list, declared like so:

```
<ul>
  <li class="yearCategory"><a href="javascript:void(0)">2011</a></li>
  <ul class="subCategory">
  <li><a href="javascript:void(0)">January</a></li>
  <li><a href="javascript:void(0)">February</a></li>
</ul>
</ul>

```

When 'January' or 'February' are selected, I would like to return the 'yearCategory' value of that certain list, in this case 2011. 

How can this be done with jQuery? I've tried experimenting with parent and parents, but have not managed to select the correct element.

This is what i've tried so far:

```
$(this).parent("ul").next("li")

```

Answer: 
firstly I'm pretty sure what you have is invalid markup your nested ul should be within the li element like so:

```
<ul>
  <li class="yearCategory">
      <a href="javascript:void(0)">2011</a>
      <ul class="subCategory">
          <li><a href="javascript:void(0)">January</a></li>
          <li><a href="javascript:void(0)">February</a></li>
      </ul>
  </li>
</ul>

```

secondly without more of your code I can't guess at how you've set this up - this is a general howto select a parent.

```
$('.subCategory li a').click( // The element that you are actually clicking is an A tag
    function()
    {
        var parent = $(this) // A tag
          .parent() // LI Tag
          .parent() // UL Tag
          .parent(); // Wrapper LI Tag

        alert($('a', parent).html()); // Output the HTML contents of the parents A tag
    }
);

```
Let's say your starting element is that a-Tag (containing the Text 'January').
To get to the value of 2011, you should do this:

```
var result = $start.parent().parent().prev().find("a").text();

```

chain would be like:
first parent gets you to "li" containing your "a".
second parent gets you to "ul" containing that "li".
prev gets you to the element before your "ul" element, so your li with class "yearCategory".
then find your a-Tag containing the text you want.

For example, if your startelement was not your "a"-Tag, but the "li"-Tag, you would need one less "parent"-Function:

```
var result = $start.parent().prev().find("a").text();

```

Hope this helps!