Javascript 第二次单击时触发jquery事件更新输入

Javascript 第二次单击时触发jquery事件更新输入,javascript,jquery,Javascript,Jquery,我需要更新jqueryajax请求和其他一些标签中的输入值,但是只有在第二次单击之后,输入才被更新。我搜索了答案,发现输入可能会丢失foucs,当我再次单击时,输入会再次被提示,但我不知道如何在输入上再次设置foucs 这是我的密码: $(oe_website_sale).on('click', 'li.installment_term', function (ev) { ev.preventDefault(); var term_id = $('

我需要更新jqueryajax请求和其他一些标签中的输入值,但是只有在第二次单击之后,输入才被更新。我搜索了答案,发现输入可能会丢失foucs,当我再次单击时,输入会再次被提示,但我不知道如何在输入上再次设置foucs

这是我的密码:

$(oe_website_sale).on('click', 'li.installment_term', function (ev) {
            ev.preventDefault();
            var term_id = $('li.installment_term.active').attr('id');
            var $parent = $ul.closest('.js_product');
            var price = $parent.find(".oe_price:first .oe_currency_value")[0].innerText;
            var down_payment = $('input.down_payment');
            ajax.jsonRpc('/calculate/term/load', 'call', {term_id, price})
                .done(function (result) {
                    price_install.text(result.price_per_month);// This line is updating perfectly from the first click
                    down_payment.val(result.down_payment); // This line has now effect only after second click
                    down_payment.attr('min', result.down_payment);// This line is updating perfectly from the first click
                });

        });
和我的html代码:

<input type="number" name="down_payment" min="0" step="0.01"
                                   class="form-control down_payment" value="0.00"/>


请共享“输入.首付”htmlcode@Rajesh我已经更新了我的代码代码看起来很好,只需确认'result.down\u payment'属性的值是否始终有效。我发现了问题,问题在于term\u id=$('li.installation\u term.active').attr('id')。。此行代码不获取单击的li id,而是获取上次单击的li id。。所以当我第一次点击时,它得到了错误的术语值,谢谢@Rajesh