Its working just fine. You must remember the fadeOut and fadeIn function are asynchronous. Meaning, the browser does not wait until the animation is done before it executes the next line of code. So as a result, your slider() function is getting called thousands of times before the animation even completed one iteration.
If you look in the console, you will see this error being thrown:
Uncaught RangeError: Maximum call stack size exceeded
Meaning you are calling the slider function too many times. The solution is to place the slider() call inside the fadeIn callback, which will be executed only once the animation is complete.
$(document).ready(function () {
slider();
function slider() {
$("#img2").fadeOut(3000, function () {
$("#img2").fadeIn(3000, function(){
slider();
});
});
}
});
Jsfiddle
slider()right after.fadeOut, but the first thing slider does is thefadeOutagain. A fiddle or at least a description of what par of it isn't working would be nice.