MozTW 討論區 https://forum.moztw.org/ |
|
FireFox的bug https://forum.moztw.org/viewtopic.php?f=18&t=17434 |
第 1 頁 (共 1 頁) |
發表人: | lalin [ 2007-01-26, 15:17 ] |
文章主題 : | FireFox的bug |
<table id="list"> <tbody> <tr> <td></td> </tr> </tbody> </table> <script> alert(document.getElementById("list").childNodes.length); </script> 這個答案怎麼會是3呢??? <table id="list"><tbody> <tr> <td></td> </tr> </tbody></table> <script> alert(document.getElementById("list").childNodes.length); </script> 這個答案就是1,有點扯 |
發表人: | kourge [ 2007-01-26, 16:44 ] |
文章主題 : | |
根據 W3C 的規格,whitespace 也算是 DOM 節點,在 XML 中也是如此。所謂「多出來」的兩個節點,nodeType 皆為 3,也就是 whitespace。 |
發表人: | lalin. [ 2007-01-26, 20:40 ] |
文章主題 : | 這個沒有whitespace |
這個沒有whitespace 只有enter做斷行而已, 請先試試看我說的是否正確,thanks............. |
發表人: | BobChao [ 2007-01-26, 21:36 ] |
文章主題 : | |
lalin. 寫: 這個沒有whitespace
只有enter做斷行而已, 請先試試看我說的是否正確,thanks............. enter 就是斷行字元啦?所有字元都算數(斷行會跟空白字元一起成為一個 node) http://developer.mozilla.org/en/docs/Wh ... in_the_DOM edit: 順手翻譯完了:「DOM 中的空白字元」 |
發表人: | kourge [ 2007-01-28, 16:31 ] |
文章主題 : | |
lalin. 寫: 這個沒有whitespace
只有enter做斷行而已, 請先試試看我說的是否正確,thanks............. \n 也算是 whitespace 喔... |
發表人: | lalin.. [ 2007-01-29, 09:15 ] |
文章主題 : | 受教 |
照這樣的話,要寫個程式for IE 跟 Firefox一起用的話 不寫成一行,還不能用哩..........謝謝 |
發表人: | kourge [ 2007-01-29, 13:51 ] |
文章主題 : | |
lalin.. 寫: 照這樣的話,要寫個程式for IE 跟 Firefox一起用的話
不寫成一行,還不能用哩..........謝謝 也不一定,只是程式會比較冗長一點罷了: <table id="list"> <tbody> <tr> <td></td> </tr> </tbody> </table> <script> var list = document.getElementById("list").childNodes; var childs = []; for (i = 0; i < list.length; i++) { if (list[i].nodeType != 3) {childs.push(list[i]);} } alert(childs.length); </script> |
發表人: | lalin. [ 2007-01-29, 15:06 ] |
文章主題 : | 再次感謝 |
同樣的問題,我也post到國外去 還被正名,要打Firefox,不能打FireFox 答案跟管理者一樣 兩位的作法我都會參考 沒想到管理者還要作翻譯,辛苦了(還有很多要翻吧) |
第 1 頁 (共 1 頁) | 所有顯示的時間為 UTC + 8 小時 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |