简体   繁体   English

如何从我的 Keypress 事件中获得延迟?

[英]How can I get delay from my Keypress event?

I need to make a delay for my keypress event because it only takes the second number that I press.我需要延迟我的按键事件,因为它只需要我按下的第二个数字。

$('#cuota').on('keypress', function(event) {

            var precio_origen = $('#cuota).val();

            console.log(precio_origen);

        });

The keypress event is fired when the input control's value has not been updated yet.当输入控件的值尚未更新时,将触发keypress事件。 If you want to get an event when that value is already updated, use the input event.如果您想在该值已更新时获取事件,请使用input事件。

 $("#cuota").on("input", function () { console.log($(this).val()); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> Input: <input id="cuota">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获得jquery .val()AFTER按键事件? - How can I get jquery .val() AFTER keypress event? 如何将我的 clearText 默认点击事件更改为 fabric.js 中的按键事件? - How I can change my clearText default click event to a keypress event in fabric.js? 在带有shift的按键事件中,如何获得编号键的原始键映射? - How can I get the original key map of a numbered key in a keypress event with shift? 如何在按键事件期间通过 jQuery 获取 HTML 文本输入的 NEW 值? - How can I get the NEW value of an HTML text input during a keypress event via jQuery? 如何判断keydown是否会导致按键事件,在这种情况下会忽略它? - How can I tell that keydown will cause keypress event and in that case ignore it? 如何使以下.keypress事件处理程序起作用? - How can I make the following .keypress event handler work? 如何使用Javascript在Safari中生成按键事件? - How can I generate a keypress event in Safari with Javascript? 如何在文本区域中的空间按键上触发退格事件? - How can I fire backspace event on keypress of space in a textarea? 如何通过事件侦听器将按键值传递给 function? - How can I pass a keypress value to a function, through an event listener? 如何在jquery中延迟焦点事件? - How can I delay focus event in jquery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM