keypress,keydown,输入框AFTER事件的keyup值 [英] keypress, keydown, keyup value of input box AFTER event

查看:101
本文介绍了keypress,keydown,输入框AFTER事件的keyup值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$("#last_4_cc").keyup(function()
{
    $.post('<?php echo site_url("sales/set_last_4_cc");?>', {last_4_cc: $('#last_4_cc').val()});    
});

在执行keypress()或keydown()时,我在输入密钥之前得到了值,当我输入密钥时按键,我得到密钥输入后的val()。

When doing keypress() or keydown() I get the value before the key is inputed, when I do key up, I get the val() for the after the key is inputed.

示例:

Cur值:
333

Cur Value: 333

keyPress3
Cur Val 333

keyPress "3" Cur Val 333

Cur价值:
333

Cur Value: 333

keyUp3
Cur Val 3333

keyUp "3" Cur Val 3333

为什么是这个?

推荐答案

这是预期的行为吗? KeyPress和KeyDown事件应该在执行默认操作之前被触发,之后KeyUp会触发。

This is the expected behavior? KeyPress and KeyDown events are supposed to be triggered before the default action is performed, KeyUp fires afterwards.

请看这里: http://www.quirksmode.org/dom/events/keys.html

这篇关于keypress,keydown,输入框AFTER事件的keyup值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆