在什么授权规范中定义了onChange事件? [英] In what authorative specification is the onChange event exhaustively defined?

查看:137
本文介绍了在什么授权规范中定义了onChange事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很惊讶地发现,html文档中的onChange事件在文本输入或textarea上触发,而不是在其值实际改变的时刻,但只有当焦点离开元素(如果其值已更改,当然)。

I was slightly surprised to find out that the onChange event in an html document is fired on a text input or textarea not at the very moment when its value actually changes, but only when focus leaves the element (if its value has changed, of course).

所以我正在寻找规范说明,我找不到它。我可以找到数百万个教程解释,包括W3Schools的教程,但是我找不到定义何时触发事件的标准。

So I was looking for the specification that states that, and I can't find it. I can find millions of tutorials explaining that, including W3Schools' ones, but I can't find the standard that defines when the event is expected to be fired.

在HTML5规范本身,事件的名称被列出,但没有任何说明:
http://www.w3.org/html/wg/drafts/html/master/

In the HTML5 specification itself, the event's name is listed but nothing is said about it: http://www.w3.org/html/wg/drafts/html/master/

在这个其他规范中,DOM 3级事件规范,甚至没有提到:
http:// www.w3.org/TR/DOM-Level-3-Events/

In this other spec, "DOM level 3 Events Specification", it is not even mentioned: http://www.w3.org/TR/DOM-Level-3-Events/

那么定义它的标准是什么?

So what is the standard that defines it?

推荐答案

W3C 4.01规范


on更改事件发生在控件失去输入焦点并且
值从获得焦点后被修改。

"The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus".

MSDN


当内容提交时,此事件被触发,而
值正在变化。例如,在文本框中,当用户正在键入时,此事件不会被释放
,而是当用户通过离开具有焦点的文本框来提交更改
时。
另外,当控件也是
失去焦点时,此事件在 onblur 指定的代码之前执行。

"This event is fired when the contents are committed and not while the value is changing. For example, on a text box, this event is not fired while the user is typing, but rather when the user commits the change by leaving the text box that has focus. In addition, this event is executed before the code specified by onblur when the control is also losing the focus."

最后,在 MDN


根据表单元素的种类更改和用户与元素交互的方式
,更改事件在
不同的时刻触发:

Depending on the kind of the form element being changed and the way the user interacts with the element, the change event fires at a different moment:


  • 当元素通过点击或使用键盘< input type =radio> < input type =复选框> ;;

  • 当用户明确提交更改(例如,从< select> 的下拉菜单,通过从< input type =date> 的日期选择器中选择一个日期,通过选择一个文件
    在文件选择器fo r < input type =file> 等);

  • 当元素在其值更改后失去焦点但不承诺(例如在编辑< textarea> < input type =text> )的值之后。 li>
  • When the element is activated (by clicking or using the keyboard) for <input type="radio"> and <input type="checkbox">;
  • When the user commits the change explicitly (e.g. by selecting a value from a <select>'s dropdown with a mouse click, by selecting a date from a date pickier for <input type="date">, by selecting a file in the file picker for <input type="file">, etc.);
  • When the element loses focus after its value was changed, but not committed (e.g. after editing the value of <textarea> or <input type="text">).

另一个有用的链接 - WhatWg - 规范 - 更改事件

Another potentially useful link - WhatWg - specification - change event.

这篇关于在什么授权规范中定义了onChange事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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