简体   繁体   English

jQuery键和鼠标单击

[英]jquery keyup and mouse click

My code: 我的代码:

<input class="quantity" type="text"  value="33000">
<script>    
   $(document).ready(
   $('.quantity').keyup(function (event) {
       alert('up');
       MyVeryImportantValidate($(this), event.key)                  
   });
   ..
</script>

My problem, if introduced into the Input still holding the keys and mouse make click on any other element in page... event keyup does not work. 我的问题是,如果引入到Input中时仍然按住键和鼠标,请单击页面中的任何其他元素...事件键入不起作用。

I think the documentation in jquery states it clearly, it is going to the item that has focus. 我认为jquery中的文档清楚地说明了这一点,它将转到具有重点的项目。

http://api.jquery.com/keyup/ http://api.jquery.com/keyup/

The keyup event is sent to an element when the user releases a key on the keyboard. 当用户释放键盘上的键时,会将keyup事件发送到元素。 It can be attached to any element, but the event is only sent to the element that has the focus. 它可以附加到任何元素,但是事件仅发送到具有焦点的元素。 Focusable elements can vary between browsers, but form elements can always get focus so are reasonable candidates for this event type. 在浏览器之间,可聚焦元素可以有所不同,但是表单元素可以始终获得焦点,因此是此事件类型的合理候选对象。

In fact the focus is lost even on holding a key down in this input text area. 实际上,即使在此输入文本区域中按住键也失去了焦点。 If I hold down the a letter key it repeats until I click outside it changing the focus. 如果按住字母键,它会重复执行,直到我在其外部单击以更改焦点为止。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM