Is there a way that I can change my parallax image when an event is fired? I am using parallax.js and I cannot seem to figure out a way.
Here's the HTML:
<div class="bg-page-index">
img_link_1
</div>
<div class="bg-page-index">
img_link_2
</div>
<div class="bg-page-index">
img_link_3
</div>
<div id="hero">
<div class="product-color-list">
<div class="color"></div>
<div class="color"></div>
<div class="color"></div>
</div>
</div>
JS:
$(".color").click(function() {
var indexNum = $(".product-color-list .color").index(this);
sliderInit(indexNum);
});
var $hero = $("#hero"),
$bg_index = $(".bg-page-index"),
bg_init = $bg_index.eq(indexNum).html();
$hero.parallax({
imageSrc: bg_init,
speed: 0.7
});
This works the first time, but it won't work a second time because the parallax.js library changes things around with the element. Does anyone know a better way of doing this, or how to reinitiate the library?