FireFox对TABLE中各元素的firstChild属性的处理(续)

听说HTML 5.0已经有一段时间了,但是并不知道它到底做了什么改进,这两天就看了下Specification,发现了下面一段话:

The markup snippet at the top of
this section

would be turned into the following DOM tree:

  • DOCTYPE: html

  • html

    • head

      • #text

        : ⏎␣␣

      • title

        • #text

          : Sample page

      • #text

        : ⏎␣

    • #text

      : ⏎␣

    • body

      • #text

        : ⏎␣␣

      • h1

        • #text

          : Sample page

      • #text

        : ⏎␣␣

      • p

        • #text

          : This is a

        • a

          href

          ="demo.html

          "

          • #text

            : simple

        • #text

          : sample.

      • #text

        : ⏎␣␣

      • #comment

        : this is a comment

      • #text

        : ⏎␣⏎

才发现在两个节点中插入一个#text节点是HTML5.0的标准,并不是只针对Table的特殊情况。先BS一下自己孤陋寡闻,继续努力!

由于Firefox 3.5支持HTML5.0,就写了一个简单的程序进行测试,验证了一下:

<html>
<head>
<title>Test HTML5.0</title>
</head>
<body>
<div id="div1">
<span>ddd</span>
</div>
<p>This is a test program for HTML5.0.</p>

<input type="button" value="test" onClick="testP()">
<script language="javascript"><!--
function testP(){
alert(document.body.firstChild.nodeName);//#text
alert(document.getElementById('div1').firstChild.nodeName); //#text
}

// --></script>
</body>
</html>

时间: 2024-08-01 14:19:33

FireFox对TABLE中各元素的firstChild属性的处理(续)的相关文章

FireFox对TABLE中各元素的firstChild属性的处理

前几天测试一个小程序,其中需要获取表格中某行第一个单元格自定义的属性值,很自然地就用到: tr.firstChild.getAttribute('bill_id'); 这行代码在IE6上可以正确执行,但是在FireFox3.5上却没有结果.错误提示:不支持该属性或方法.根据经验判断,应该是tr或者tr.firstChild二者中有一个没有获取正确的对象.于是使用tr.nodeName和tr.firstChild.nodeName进行测试,前者是tr对象没有错误,而后者的值却是#text:而此时使

Javascript遍历table中的元素示例代码

 这篇文章主要介绍了Javascript如何遍历table中的元素,需要的朋友可以参考下       例如: <table id=tb> <tr><th> </th><th> </th><th> </th><th> </th></tr> <tr><td> </td><td> </td><td> </

Javascript遍历table中的元素示例代码_javascript技巧

例如: <table id=tb> <tr><th> </th><th> </th><th> </th><th> </th></tr> <tr><td> </td><td> </td><td> </td><td> </td></tr> <tr>&

JavaScript中为元素加上name属性的方法_javascript技巧

今天遇到个小问题, 在构建 DOM 时, IE 中不能通过 element.setAttribute('name', _variable); 和 element.name = _variable; 这样的形式来为元素加上 name 属性, 无论是 IE6 还是 IE7. (IE8 是可以的, 但 IE8rc1 不行) 后来我查看了 MSDN, 得到信息如下: 复制代码 代码如下: Internet Explorer 8 and later can set the NAME attribute a

javascript 导出数据到Excel(处理table中的元素)_javascript技巧

做法: 修改Input的outerHTML; 具体例子: 复制代码 代码如下: function resetInput() { var controls = document.getElementsByTagName('input'); for(var i=0; i<controls.length; i++){ if(controls[i].type=='text') { if(controls[i].value =="") { controls[i].outerHTML=&qu

js获取浏览器高度 窗口高度 元素尺寸 偏移属性的方法_javascript技巧

如下所示: screen.width screen.height screen.availHeight //获取去除状态栏后的屏幕高度 screen.availWidth //获取去除状态栏后的屏幕高度 一.通过浏览器获得屏幕的尺寸 二.获取浏览器窗口内容的尺寸 //高度 window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight //宽度 window.innerWidth

JS获取网页中HTML元素的几种方法分析

js|网页 getElementById getElementsByName getElementsByTagName 大概介绍 getElementById ,getElementsByName ,getElementsByTagName 后两个是得到集合,byid只是得到单个对象 getElementById 的用法 举个例子: <a id="link1" name="link1" href=http://www.webjx.com>网页教学网<

jQuery实现table中的tr上下移动并保持序号不变的实例代码_jquery

jQueryMoveTr.html 代码如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>jQuery-bhang</TITLE> <script type="text/javascript" src="jquery-1.6.2.js"></sc

index-lua的元表怎么遍历不到,而且为什么也不能改变表中的元素的值呢,求详解?

问题描述 lua的元表怎么遍历不到,而且为什么也不能改变表中的元素的值呢,求详解? local function tab(t) local proxy = {} local mt = { __index = t, __newindex = function(t, k, v) error("attempt to update readonly a table") end } setmetatable(proxy, mt) return proxy end local days = tab