答案:在您开始本文的阅读前,我强烈建议您可以先读一读此篇:http://w3help.org/zh-cn/causes/SD9004.HTMLCollection 接口定义
inte易做图ce HTMLCollection
{
readonly attribute unsigned long length;
Node item(in unsigned long index);
Node namedItem(in DOMString name);
}
对于 HTMLCollection集合对象 必须要说一说的是 namedItem方法. 看看规范的解释.
原文:
namedItem method
This method retrieves a Node using a name. With [HTML 4.01] documents, it first searches for a Node with a matching id attribute. If it doesn't find one, it then searches for a Node with a matching name attribute, but only on those elements that are allowed a name attribute. With [XHTML 1.0] documents, this method only searches for Nodes with a matching id attribute. This method is case insensitive in HTML documents and case sensitive in XHTML documents.
翻译:namedItem 方法:此方法获通过 "name"属性来获取节点.在HTML4.01文档中,它首先搜索的是节点的ID属性的值. 如果没找到匹配节点,才去搜索name 属性与之匹配的节点. 即HTML4.01 DTD下,浏览器们应该优先通过ID来获取节点.其次才是name.在XHTML 1.0文档中,则仅搜索ID与之匹配的节点.对于节点(id or name)属性的值,此方法在HTML文档中忽略大小写区别,而在XHTML文档中.则要区别大小写.
上文中粗体部分很重要,没有这个作为指导的话.后面遇到的一些问题就很不好确定孰是孰非.因为众多浏览器的实现并不一样.
NodeList 接口定义
inte易做图ce NodeList {
Node item(in unsigned long index);
readonly attribute unsigned long length;
};
微软MSDN上查到的 NodeList实现 ,虽然这些资料告诉我们 NodeList继承了 Microsoft.SpeechServer.Dom.Collections.Collection Class . 但是事实却并不如此. 事实上,ie浏览器的NodeList不具备 ICollection接口定义的 namedItem 和 tags 两个方法. 实现了他们的 只有HTMLCollection类型.此文档是 Speech Server 2007 用的,所以应该仅供参考.只能说明IE浏览器中的NodeList 还是遵守标准的.public sealed class NodeList : Collection, INodeList, IEnumerable, IExpando, IReflect
NodeList的继承链:
System.Object
Microsoft.SpeechServer.Dom.ShimMicrosoft.SpeechServer.Dom.DynamicShimMicrosoft.SpeechServer.Dom.Collections.CollectionMicrosoft.SpeechServer.Dom.Collections.NodeListCollection 实现的ICollection接口定义的属性和方法表public properties : item(msdn上说item是重载,我表示诧异...),lengthpublic methods : item,namedItem,tagsps:1. 目前只有Opera的NodeList Class 是派生自 Collection Class 或HtmlCollection Class 的.所以此浏览器中NodeList集合对象也会具备 HTMLCollection接口实现的所有属性和方法.2. MS 的ICollection 接口 定义了一个tags方法 用来根据tagName获取元素集合.其类型为 HTMLCollection 类型
神秘的 StaticNodeListinte易做图ce NodeSelector {
Element querySelector(in DOMString selectors);
NodeList querySelectorAll(in DOMString selectors);
}
The NodeList object returned by the querySelectorAll() method must be static, not live ([DOM-LEVEL-3-CORE], section 1.1.1)
由于w3.org的[DOM-LEVEL-3-CORE]文档中,并没有StaticNodeList接口的定义. 只好在后面找出一份微软的代替之.微软的一些相关:基于 NodeList Class 是个密封类. 我们可以初步了解StaticNodeList 并不像最初我认为的那样,可能派生自NodeList. 而且规范说的明白. 这个集合是静态的.就是说它不会随着DOM树的变化而变化. 这种选择性去除基类能力的做法不符合继承的思想.所以只可能是另外的一个东东了.Members Table
The following table lists the members exposed by the StaticNodeList object.
Attributes/Properties
Property Description length Gets the number of characters in a TextNode object. Methods
Method 上一个:基于jquery的关于动态创建DOM元素的问题
下一个:Javascript动态绑定事件的简单实现代码更多图片编程知识:
- 更多JS疑问解答:
- 几个验证11位手机号码格式的js代码
- js把图片转换成 base64代码
- js把base代码转换成图片
- JS 将 base64编码的图片转化为图片文件
- js中的定时器
- js如何获得FCKeditor控件的值
- 用js限制投票的cookie .目前设置的为:<input type="" class="" onclick="'window.location...
- JS验证,这块“牛皮”反复修改都不能实现
- 在JS中使用DOM模型
- 如何用JS 获取本地文件夹的文件列表
- js中new 了两个Object数组。怎么样将数组内容合并,重复的内容?
- 求实现自动生成图片缩略图的JS代码
- JS脚本网页问题
- js,代码中"object"和"Object"区别?
- js+flash实现网页图片切换效果,出现边框,单击激活此控件。
- asp
- php
- Delphi
- Matlab
- JSP
- Foxpro
- JS
- C/C++
- C#/ASP.NET
- VC++
- JAVA
- VB
- 汇编语言
- html/css
- CGI
- XML/UML
- wap
- 网站相关
- 网页素材
- python
- 微信小程序
- thinkphp
如果你遇到编程学习难题:
访问www.zzzyk.com 试试CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,