html5 - Change background image with the slider image simultaneously - jquery/css -


I want to change the background image when the slider rotates the other image together with an image. For this example, Added a Bootstrap Carousel slider with background image. I want that when the slider slides the image, the background image will also change / slide at the same time. I used the first two bootstrap carousel sliders, one was the main slider and the other was the background slider. But I need to add only one main carousel slider and background image which also changes from the main slider image. Here's my example url link () where I want to use this type of functionality. You can change the background image with JQuery like any other CSS property:

  $ ("header"). CSS ('background', 'url (path to my image)');  

If you want to be triggered by the slide event, follow this example from the Bootstrap docs:

  $ ('# myCarousel') ('Slide.bs.carousel', function () {$ ("header"). Css ('background', 'url (path to my image)');});  

Hope that helps, DB


Comments