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: 
Adjust your mark up slightly since the original wasn't valid:

```
<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>

```

And the jQuery:

```
$(document).ready(function() {
    $('ul.subCategory li a').click(function() {
        var year = $(this)
                     .parent()
                     .parent()
                     .parent()
                     .find('a')
                     .text();

        alert(year); // or whatever you want to do with the year
    });
});

```
Given the mark-up you have provided, this should work -

```
$("a").click(function () {
    alert($(this).parents('ul').find('li.yearCategory > a').text())
}) 

```

Working demo - <http://jsfiddle.net/ipr101/Krtcs/>

You'd have to be careful with this as it will fire for all 'a' clicks, but will only work when the link is nested in the same way that the 'January' and 'February' links are.

Also, as Tomalak Geret'kal points out in the comments below the code will work with the mark-up provided in the OP, it could fail depending on the mark-up surrounding it.