I'm looking for a way to display the img
title & alt
tags in a div
(.image-caption
).
This is my code so far:
owl.on('changed.owl.carousel', function(event) {
var comment = $(this).find('img').attr('alt');
var title = $(this).find('img').attr('title');
if(comment) $('#desktop .image-caption').html('<h4>'+title+'</h4><p>'+comment+'</p>');
})
Any ideas? Thanks!
You can use
translated.owl.carousel
event for thatHere is a working Fiddle
UPDATE:
Slightly improved code and added functionality to update image caption on carousel load.
FIDDLE
this works:
try it: https://jsfiddle.net/wx0ovpzh/49/