I answered a similar question not that long ago.
DEMO http://jsfiddle.net/kevinPHPkevin/7VzaQ/3/
$('.cycle-slideshow').on('cycle-before', function (event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
var bg = $(incomingSlideEl).find('img').css('backgroundColor');
$('body').css('background', bg);
});
Hope this helps
[edited] I've edited the code so now it assigns the same class to the body that is assigned to the active slide
DEMO http://jsfiddle.net/kevinPHPkevin/7VzaQ/4/
Just to explain what i did - As you can see in the above code i creat a var
called bg
. This var
is the CSS background color of the active slide. I then assign that var
to the background of the body tag. As you requested you wanted a class change, not just a style change. In light of this i simply changed the code so that it is finding the attr
class
rather than the CSS background color.
Var Snippet before:
var bg = $(incomingSlideEl).find('img').css('backgroundColor');
$('body').css('background', bg);
Var snippet after:
var bg = $(incomingSlideEl).find('img').attr('class');
$('body').attr('class', bg);