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

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