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
    }
);

```
A possible solution could be the following:

```
$("li.yearCategory a:fisrt", $(anchorNode).parent().parent()).text();

```

...but to simplify things I would add an id to the parent ul, by allowing a simple selector like:

```
$("ul#myid li.yearCategory a:first").text()

```