admin管理员组文章数量:1406924
How can i show (in the div) the image alt after each move ? I try this but it's not working (I get always the first alt)
<div id="owlSlider" class="owl-carousel owl-theme">
<div class="item"><img src="lg/img_1.jpg" alt="Image 1" class="img-responsive"></div>
<div class="item"><img src="lg/img_2.jpg" alt="Image 2" class="img-responsive"></div>
<div class="item"><img src="lg/img_3.jpg" alt="Image 3" class="img-responsive"></div>
</div>
<div><p id="legend" style="font-size:1.4em"> </p></div>
$("#owlSlider").owlCarousel({
navigation : false,
pagination: true,
slideSpeed : 300,
paginationSpeed : 400,
singleItem:true,
autoPlay:true,
transitionStyle : 'fade',
rewindNav: true,
afterMove : function (elem) {
var leg = elem.find('img').attr('alt');
//console.log(elem);
$('#legend').html(leg);
}
});
Thanks for your help...
How can i show (in the div) the image alt after each move ? I try this but it's not working (I get always the first alt)
<div id="owlSlider" class="owl-carousel owl-theme">
<div class="item"><img src="lg/img_1.jpg" alt="Image 1" class="img-responsive"></div>
<div class="item"><img src="lg/img_2.jpg" alt="Image 2" class="img-responsive"></div>
<div class="item"><img src="lg/img_3.jpg" alt="Image 3" class="img-responsive"></div>
</div>
<div><p id="legend" style="font-size:1.4em"> </p></div>
$("#owlSlider").owlCarousel({
navigation : false,
pagination: true,
slideSpeed : 300,
paginationSpeed : 400,
singleItem:true,
autoPlay:true,
transitionStyle : 'fade',
rewindNav: true,
afterMove : function (elem) {
var leg = elem.find('img').attr('alt');
//console.log(elem);
$('#legend').html(leg);
}
});
Thanks for your help...
Share Improve this question edited May 6, 2014 at 15:37 Joshua Taylor 86k9 gold badges162 silver badges364 bronze badges asked Apr 22, 2014 at 7:25 ChrisChris 4351 gold badge8 silver badges21 bronze badges1 Answer
Reset to default 6Try it:
..
afterMove : function (elem) {
var current = this.currentItem;
var alt = elem.find(".item").eq(current).find("img").attr('alt');
console.log('Imagem current is ' + alt);
}
本文标签: javascriptOWL Carousel afterMove get img altStack Overflow
版权声明:本文标题:javascript - OWL Carousel afterMove get img alt - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744371521a2603050.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论