0
Guys, I’m trying to make a slide that when changing image also change the background image of div "banner"
along with the slide image, someone can help me?
<html>
<head>
<title>Testando slide</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.css">
</head>
<body>
<div class="banner" style="width: 700px; height:300px; padding: 60px;">
<div class="slider" style="margin: auto;">
<div class="img-slider" data-color="1"><img src="imgs/1.jpg" width="600" height="250"/></div>
<div class="img-slider" data-color="2"><img src="imgs/2.jpg" width="600" height="250"/></div>
<div class="img-slider" data-color="3"><img src="imgs/3.jpg" width="600" height="250"/></div>
<div class="img-slider" data-color="4"><img src="imgs/4.jpg" width="600" height="250"/></div>
<div class="img-slider" data-color="5"><img src="imgs/5.jpg" width="600" height="250"/></div>
<div class="img-slider" data-color="6"><img src="imgs/6.jpg" width="600" height="250"/></div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.min.js"></script>
<script>
$(document).ready(function(){
$('.slider').bxSlider({
auto: true,
stopAuto: true,
slideWidth: 600,
onSlideNext: function($slideElement, oldIndex, newIndex){
var corSlide = $('.img-slider').eq( newIndex ).data('color');
$('.banner').css({ 'background': 'url("imgs/' + corSlide + '.jpg") no-repeat fixed'});
}
});
});
</script>
</body>
</html>