开发者

Event Evaluation

开发者 https://www.devze.com 2023-02-18 03:56 出处:网络
When does a JavaScript event like keydown actually get evaluated. ie. Till when can one use event.preventDefault() or similar methods to prevent the action from being taken.

When does a JavaScript event like keydown actually get evaluated. ie. Till when can one use event.preventDefault() or similar methods to prevent the action from being taken.

I haven't had any luck in trying to find a pattern. All I know that is that if the prevent is executed at the beginning or a statement lat开发者_运维技巧er, it works(prevents action) but a little later, it doesn't.

Is there any reference for this?


It's probably browser dependent. If you want to prevent the default then that instruction should always be the first (no motif not to be, it's instantaneous) and only then follow up with your code.

check the example in http://api.jquery.com/keydown/

0

精彩评论

暂无评论...
验证码 换一张
取 消