I am trying to insert an address into an input field upon clicking a button that is its sibling.
HTML
<label for="to">To:</label>
<input type="text" id="to" name="to" required="required" placeholder="An address" size="30" />
<a id="to-link" href="#" class="button">Get my position</a>
<a id="to-home" href="#" class="button">Home</a>
<label for="from">From:</label>
<input type="text" id="from" name="from" required="required" placeholder="Another address" size="30" />
<a id="from-link" href="#" class="button">Get my position</a>
<a id="from-home" href="#" class="button">Home</a>
Jquery
jQuery("#from-home, #to-home").click(function(event) {
event.preventDefault();
jQuery(this).prev("input").val("123 my street, 12345 Gotham");
});
I don't know what I'm doing wrong but I don't get anything if I console.log(jQuery(this)); Sorry if this is a dumb question I'm just starting to get my head around "this" (or at least I thought I was.)