Question: I'm trying to get the value of the input field with class `keyHash` when I click on the link with class `loadKey`. However, all I keep getting is `undefined`?

How is this done? Shouldn't this have worked?

[Fiddle](http://jsfiddle.net/v25kt10r/2/)

```
<div class="accounts hash">
    <input type="text" class="input-tiny keyHash">
    <i class="icon-plus loadKey">Click</i>
</div>

$('.loadKey').live('click', function() {

    alert($(this).closest('.keyHash').val());

});

```

Answer: 
by documentation of closest, it is checks only the current element, and then its ancestors, in your case the input field is not ancestor, it is sibling

<http://api.jquery.com/closest/>

you can not acheive this using closest only
$('.loadKey').click(function() {

```
alert($(this).prev().val());

```

});

OR 

$('.loadKey').click(function() {

```
alert($(this).prev('.keyHash').val());

```

});