$(document).ready(function(){ $(".button").click(function(){ $(".slider_image").fadeOut(1000,function(){ $(".slider_image").css("background-image","url("+image[n]+")");$(".slider_image").fadeIn(); }); });});