1

I have some code (below) which I wrote for a small piece of text to fade in out through a cycle of around 4 paragraphs. It works, but whenever I bring up the Web Inspector, it just tells me that it's an 'Anonymous function'. This is really annoying. Does anyone know how to fix it?

Btw, the bit that it hightlights as an anonymous function is:

slides[current].fadeOut("slow");
slides[target].fadeIn("slow");

The whole extract of code is here:

$(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();
});

I made a jsfiddle here.

Grant Thomas
45.1k10 gold badges88 silver badges129 bronze badges
asked Sep 17, 2012 at 12:13
4
  • Fix what? What's the problem? What did you expect? I don't see anything wrong on your code nor Chrome Dev Tools. Commented Sep 17, 2012 at 12:18
  • 1
    Apart from the lacking comma after $('#widget p') which makes those globals of course. Commented Sep 17, 2012 at 12:19
  • Yeah, but everytime I bring up the Inspector, it tells me it's an anonymous function. I understand that it's not an error, but how can I stop it from coming up every time I bring up the dev tools? Commented Sep 17, 2012 at 12:29
  • Do you have a console.log anywhere in your code? Your fiddle and posted code does not generate any message on my console. Commented Sep 17, 2012 at 12:30

1 Answer 1

1

Because it is an anonymous function, as opposed to a named function.

One potential solution could be to roll the code into a named function and reference that function by named for the init option.

answered Sep 17, 2012 at 12:15
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.