在 html5 中,使用 INPUT type='date'与 DATE - 没关系
这个问题没有实际意义 - 请参阅@Alochi 评论。我的错。
这与 button
不同,因为 button
是规范中定义的标签,而其他类型,日期、电话、密码、隐藏,... 不是,但实际上可以用来创建 html。 (这个< /a> 是我能找到的最好的链接)。
根据我的实验,在现代浏览器上,以下内容是等效的:
a = document.createElement('input');
a.type = 'date';
b = document.createElement('date');
a
和 b
呈现相同的效果并具有相同的属性。 错误!!做不呈现相同的
最大区别是querySelector
是严格 - 即使date
可能相当于< code>input[type='date'] 从功能上讲,使用 date
创建的元素将无法通过 input[type='date']
找到,反之亦然反之亦然。
在处理这些人时,如果我们要寻找他们,似乎我们将需要两组查询 - 或者是否有一些超集可以使它更容易?
这是实施者超出规范的情况吗?看起来他们正在将所有类型迁移到自己的元素,就像他们对 button
所做的那样。
(假设不关心旧版浏览器)这里有什么指导原则吗?
This question is moot - see @Alochi comments. my bad.
This is different than button
in that button
is a defined tag in the specs, whereas other types, date, tel, password, hidden, ...
, are not but in practice can be used to create html. (this is the best link I can find).
from my experiments, on modern browsers the following are equivalent:
a = document.createElement('input');
a.type = 'date';
b = document.createElement('date');
a
and b
render the same and have the same attributes. wrong!! do not render the same
the big difference is that querySelector
is strict - even though date
might be equivalent to input[type='date']
functionally, an element created with date
will not be found with input[type='date']
and vice versa.
in dealing with these guys it seems like we're going to need two sets queries if we're looking for them - or is there some superset that makes it easier?
is this a case where implementers are outrunning the specs? it seems they are migrating all of the types to their own element, much like they did with button
for example.
(assuming one does not care about legacy browsers) are there any guiding principles here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您从哪里获得有关
date
标签的信息?没有这样的标签,看:
http://www.w3schools.com/html5/ html5_reference.asp
http://dev.w3.org/html5/spec/Overview.html
中的“块级语义”,只有
time
,在该部分关于表单,有input type="date"
,以及button
、keygen
和meter
等标签但任何地方都没有
。Where did you get that about the
date
tag from?There is no such tag, look:
http://www.w3schools.com/html5/html5_reference.asp
http://dev.w3.org/html5/spec/Overview.html
in the “block level semantics”, there is only
time
, in the section about forms, there isinput type="date"
, as well as tags likebutton
,keygen
andmeter
but no
<date>
anywhere.我在 Opera 中看到了日期选择器
看到左上角的小框 http://www.shaneofalltrades.com/electrical.html(如果您有 Opera)。我加载这个只是为了示例,没有任何处理。也适用于 Safari,但只有更简单的形式,不适用于 IE9 或 Firefox 6。
I have seen the date picker in Opera as
<input type="date">
see the small box in top left at http://www.shaneofalltrades.com/electrical.html if you have Opera. I loaded this just for sample, no process with it. Also works in Safari but with only a simpler form and does not work in IE9 or Firefox 6.