I am trying to use jquery to set the input field value to the text inside the option field when the user clicks on it. This will require keeping record of the last input field that was focused on, so I can later set its value when the user click on an ‘option’.
Markup
<div class="option">apples</div>
<div class="option">oranges</div>
<div class="option">pears</div>
<input type="text" value="default" class="fruit-name"/>
<input type="text" value="default" class="fruit-name"/>
<input type="text" value="default" class="fruit-name"/>
JQuery (With pseudo code)
$(document).ready(function(){
$('.fruit-name').click(function(){
$('.option').click(function(){
$((this)(fruit-name)).val($((this)(option)).text());
});
});
http://jsfiddle.net/jgBxs/