我想创建一个函数来复制owl-carousel上一个和下一个活动项的h3标签,并在next和prev箭头中显示它,但我在jQuery函数中不是很先进 .

enter image description here

我写了一个代码,但它不适用于所有轮播功能(拖动,滑动,点击下一个等)

$( document ).ready(function() {
    $( ".testimonials-section .owl-nav button.owl-next").html('<div class="next-item-name"></div>');

    var h3text = $(".testimonials-section .container .owl-item.active").next().find('h3').text(); 

    $(".testimonials-section .owl-nav button.owl-next .next-item-name").append(h3text);
});