jQuery background image rotation script - looking to modify

karolina

New Member
I'm using this nice little jQuery script to rotate a background image:http://www.diplo.co.uk/blog/2011/2/23/simple-jquery-background-image-rotator.aspxThe jQuery in question is here:\[code\](function($){ $.fn.extend({ bgrotate: function(options) { var defaults = { delay: 1000, images: [], imagedir: "/images/" } var o = $.extend(defaults, options); var $obj = $(this); var cache = []; var i = 0; var preCache = true; return this.each(function() { setInterval(function() { setBack($obj, o.images, o.imagedir) }, o.delay); }); function setBack(elem, backgrounds, imagedir) { elem.css("background-image", "url(" + imagedir + backgrounds + ")"); i++; if (i == backgrounds.length) { i = 0; preCache = false; } if (preCache) { var cacheImage = document.createElement('img'); cacheImage.src = http://stackoverflow.com/questions/14500836/imagedir + backgrounds; cache.push(cacheImage); } } } });})(jQuery);\[/code\]This works great, but I'm trying to add a fade between image rotation.Any pointers or clues as to how / where a fading element might be added to this script?Many thanksDave
 
Back
Top