当前位置: 移动技术网 > IT编程>网页制作>Html5 > HTML5通用接口详解

HTML5通用接口详解

2019年07月25日  | 移动技术网IT编程  | 我要评论

1.先说几个基本类型: domstring, boolean, long, unsigned long, double,

nan(not-a-number)。

domstring其实就是其它大家常用的语言中的string。 在html5中,它用于表示url,dom内容等等。其他的boolean(布尔), long(长整型), unsigned long(无符号长整型), double(浮点数)我想不用我详述,大家都能清楚。至于nan我想大部分js老鸟也都清楚其意义,就是在一个无穷大

或者非数字的值。

官方文档里没有介绍undefined和null,至于为什么,希望能有高手给予解答~~

2. 集合类型包括: htmlcollection, htmlallcollection,
htmlformcontrolscollection, htmloptionscollection, and
htmlpropertiescollection。

htmlcollection是一个泛型集合,也是一个集合的基础接口,它提供了三个attributes:
length, item, nameditem.

length是集合的长度。
item(index)可以用索引值获取集合中的元素。
nameditem(name)可以用元素的name获取元素。

实际上你也可以直接用collection[index],collection(index)或collection

[name],collection(name)获取集合中的元素。

htmlallcollection继承自htmlcollection接口,他包含以下属性:

length和item属性跟htmlcollection的一样。

nameditem(name)区别于htmlcollection的是它有可能返回的是一个集合。

tags(tagname)用tagname返回一个集合。

同样你也可以直接用collection[index],collection(index)或collection

[name],collection(name)获取集合中的元素,当那么值匹配多个元素时返回一个

htmlallcollection。

htmlformcontrolscollection是一个以form和fieldset为元素的集合。同样继承自

htmlcollection接口。

有htmlcollection的所有属性,并另外增加了radionodelist接口。它继承自nodelist。

其实radionodelist按定义上来说就是一个radiobutton的集合。我比较好奇这样一个list放

在htmlformcontrolscollection里的用意。

htmloptionscollection是一个option的集合,继承自htmlcollection接口,它一般用

于操纵select标签的子元素。

htmloptionscollection特有的属性有:add(option),remove(index),selectedindex

add方法有两个重载

void add(in htmlelement element, in optional htmlelement before);
void add(in htmlelement element, in long before);

增加一个元素第一参数必须,后面的参数是可选的

remove(index)以索引删除一个元素。

selectedindex相信大家都能明白。

以上这篇html5通用接口详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

原文地址:

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网