gpt4 book ai didi

javascript - oninput 在 Chrome 中是否适用于单选按钮?

转载 作者:可可西里 更新时间:2023-11-01 13:00:11 26 4
gpt4 key购买 nike

有人知道 oninput 标签在 Chrome 中是否适用于单选按钮吗?这是我的代码:

<html>
<head><title>Weirdness</title></head>
<body>
<input type="number" min="1" size="2" oninput="window.alert(this.value);">
<input type="radio" name="myradio" value="A" oninput="window.alert(this.value);">
<input type="radio" name="myradio" value="B" oninput="window.alert(this.value);">
</body>
</html>

当我在 Firefox 中运行它时,当我更改其中一个输入时,window.alert() 调用工作得非常好。但是当我在 Chrome 上运行它时,当我选择一个单选按钮时,单选按钮不会调用该函数。这个,尽管我发现所有的规范都说 Chrome 支持 oninput。还是我做错了什么?

谢谢。

最佳答案

您可以随时查看the documentation有疑问时。

Feature        Chrome   Firefox (Gecko) Internet Explorer   Opera   Safari 
Basic support (Yes) 2 9 10 (Yes)

然而,根据Living Standard , 事件是...

Fired at controls when the user changes the value (see also the change event)

由于单击按钮、复选框或单选按钮实际上并没有改变它的值,因此从技术上讲,它可能不应该被触发或依赖于触发单选按钮。

我可以确认它在 Chrome 48 中不起作用。

关于javascript - oninput 在 Chrome 中是否适用于单选按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40900048/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com