$("a").click(function() {
$("input").val($(this).text());
});
But you would be better off assigning classes or identifiers to them, for example:
<input class="location" type="text" title="Ort, gata eller kommun" value="something">
<a href="#" class="location">Teramo, Italy</a>
$("a.location").click(function() {
$("input.location").val($(this).text());
});
Or, target the entry with respect to the anchored anchor through a bypass, for example:
$("a").click(function() {
$(this).prev("input").val($(this).text());
});
source
share