[已解决问题] ff能运行ie不能运行
提问时间: 2008-05-27 16:41
浏览:326 次
<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 &&
提问者:cloudgamer - 初学一级

问题补充:<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>

最佳答案
只能说明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]
2008/5/27 18:44:21 回答者:玉开
其它回答(1)
请先把问题写清楚了~
4个月前   回答者:wbiner - 菜鸟二级
评论
   您需要登录以后才能回答!
 

我要提问

我的问题


快到期问题

> 问题排行榜

相关内容

相关链接