首页 新闻 会员 周边 捐助

ff能运行ie不能运行

0
[已解决问题] 解决于 2008-07-12 14:21
<SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ul </SPAN><SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000ff">="tt"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">li</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">111 </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">li</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">li</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">111 </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">li</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">li</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">111 </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">li</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">li</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">111 </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">li</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ul</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR>Object.prototype.Each </SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(fun) {<BR>&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">this</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">.length </SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;&amp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">
问题补充: <ul id="tt"> <li>111 </li> <li>111 </li> <li>111 </li> <li>111 </li> </ul> <script> Object.prototype.Each = function(fun) { if(this.length && this.length > 0){ for (var i = 0; i < this.length; i++) fun(this[i], i); } } var objs = document.getElementById("tt").getElementsByTagName("li"); objs.Each(function(obj, index){ alert(index); }) </script>
cloudgamer的主页 cloudgamer | 菜鸟二级 | 园豆:280
提问于:2008-05-27 16:41
< >
分享
最佳答案
0
只能说明ie下document.getElementById("tt").getElementsByTagName("li")返回的类型不是Object。下面的脚本可以在ie下执行,说明Array是Object;具体getElementsByTagName在ie下返回的是什么还不清楚。 [code] <script> var objs = document.getElementById("tt").getElementsByTagName("li"); var a = new Array(); for(var i in objs){ a.push(i); } a.Each(function(obj, index){ alert(index); }); </script> [/code]
玉开 | 大侠五级 |园豆:8822 | 2008-05-27 18:44
其他回答(1)
0
请先把问题写清楚了~
zh-cn@live.com | 园豆:230 (菜鸟二级) | 2008-05-27 17:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册