Skip to content

Instantly share code, notes, and snippets.

@goranefbl
Created October 21, 2015 15:35
Show Gist options
  • Save goranefbl/59a7e45a8e3049175346 to your computer and use it in GitHub Desktop.
Save goranefbl/59a7e45a8e3049175346 to your computer and use it in GitHub Desktop.
Owl Slider Image as Background Image
$(document).ready(function() {
$("#owl-demo").owlCarousel({
navigation : true,
slideSpeed : 300,
paginationSpeed : 400,
singleItem : true,
afterInit: afterOWLinit
});
function afterOWLinit(elem){
$.each(this.owl.userItems, function (i) {
imageUrl = $(".owl-wrapper").children().eq(i).find("img").attr("src");
$(".owl-wrapper").children().eq(i).css('background-image', 'url(' + imageUrl + ')');
imageUrl.hide();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment