我有一些代码(下面),我写了一小块文字,以淡出一个循环约4段。它可以工作,但是每当我提到Web检查器时,它都会告诉我它是一个“匿名函数”。这真烦人。有人知道怎么修吗?
顺便说一句,它以匿名函数的高度显示的比特是:
slides[current].fadeOut("slow");
slides[target].fadeIn("slow");代码的全部摘录如下:
$(document).ready(function() {
var About = {
init: function() {
var slide_images = $('#widget p')
slides = new Array(),
delay = 5,
current = 0;
slide_images.each(function(index) {
current = index;
slides.push($(this));
});
var interval = setInterval(function() {
target = (current < (slides.length - 1)) ? current + 1 : 0;
slides[current].fadeOut("slow");
slides[target].fadeIn("slow");
current = target;
}, delay * 750);
}
}
About.init();
});我做了个小提琴这里。
发布于 2012-09-17 12:15:20
因为它是一个匿名函数,而不是命名函数。。
一个潜在的解决方案可能是将代码滚动到一个命名的函数中,并以init选项命名引用该函数。
https://stackoverflow.com/questions/12458932
复制相似问题