2012-01-22 97 views
1

我在我的画廊页面上部署了两个函数。一个显示一个一个 - 列表项目与图像,两个检查并删除图像(外部)不会加载的项目。递归jquery函数,然后检查

第一个很好,但第二个没有。无法弄清楚原因。有人知道这个吗?

var r = 0, 
    selector = "ul.display li:hidden:first"; 

function fadeIn($item) { 
    $item.fadeIn(200, function() { 
     var n = $(selector); 
     if (n.length > 0) { 
      fadeIn($(selector)); 
     } else { 
      // add a div 
      $(".navigate").show("fast"); 
      $("#downunder").show("slow"); 
     } 
    }) 
} 


fadeIn($(selector)); 
function myFunc() { 
    $("ul.display li img").each(function(index) { 
     if ((!this.width || !this.height)) { 
      pos3 = $(this).attr("id"); 
      reportrefcam(); 
      $(this).parent().parent().remove(); 
     } 

     $(this).error(function() { 
      pos3 = $(this).attr("id"); 
      reportrefcam(); 
      $(this).parent().parent().remove(); 
     }); 
    }); 
}; 

myFunc(); 
+0

你为什么把这个函数放在一个变量中?函数myFunc(){'会。 – Lg102

+1

代码是一个** lot **,它在正确缩进时更容易阅读和调试。你的'myFunc'代码缩进到处都是。 –

+0

TJ:我已经做出了更可读的标记 – mark

回答

0

我想我看到了问题。您正在检查图像是否有宽度和高度...

this.height will not work。

可以使用:this.style.height或$(this).height();

+0

myFunc()作为一个独立的工作,现在我使用fadeIn它不是。 – mark

+0

看到我对你的问题的其他评论了解更多信息。 – Matthew