I need to add a text to input text field after clicking on a button. The button class is always the same (".button") so I think that I need to use "$(this)" but I don't know how to do it.
My code is:
HTML:
<div class="add">
<input type="text" name="input[1]" value="" class="input[1]">
<input type="button" class="button" value="add">
</div>
<div class="add">
<input type="text" name="input[2]" value="" class="input[2]">
<input type="button" class="button" value="add" value="add">
</div>
<div class="add">
<input type="text" name="input[3]" value="" class="input[3]">
<input type="button" class="button" value="add">
</div>
jQuery:
$('.button').click(function(e) {
$(this).parent('input[type=text]').val('hhh');
});
Regards :)
$(this).prev().val('hhh');