提问时间: 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 &&
问题补充:<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>