I want o display value in to two different field according to input is focused. When I put cursor in any one of two field and click on button, I want to only value of button appear in that field. but my code is keep adding value to the same field event I have two different fields. Anybody please help.
<input type="text" class="frm-control-input" name="multi">
<input type="text" class="frm-control-input-price" name="price">
<button type="button" class="btn" value="1">1</button>
<button type="button" class="btn" value="2">2</button>
<button type="button" class="btn" value="3">3</button>
$('.frm-control-input').click(function(){
if($(this).is(':focus')){
console.log('up')
$('.btn').click(function(){
var number = $(this).val();
$('.frm-control-input').val($('.frm-control-input').val() + number);
console.log(number);
});
}else{
$(this).blur();
}
});
$('.frm-control-input-price').click(function(){
if($(this).is(':focus')){
$('.btn').click(function(){
var num = $(this).val();
$('.frm-control-input-price').val($('.frm-control-input-price').val() + num);
});
}
});