gpt4 book ai didi

jquery - 在 Bootstrap 轮播的事件幻灯片中查找元素

转载 作者:行者123 更新时间:2023-12-01 07:52:23 25 4
gpt4 key购买 nike

我正在尝试对 Bootstrap 3 轮播中的 div 执行某些操作。但是我如何找到那个 div 呢?

 $('.carousel').on('slid.bs.carousel', function () {
var carouselData = $(this).data('bs.carousel');
var currentIndex = carouselData.getItemIndex(carouselData.$element.find('.item.active'));

//now I know the current item, but how do I change the .description div
//inside that item?


});

最佳答案

您的解决方案即将完成。对于任何寻找解决方案并登陆此处的人:

$('.carousel').on('slid.bs.carousel', function (e) {
// mind the e parameter I added ^ here
var carouselData = $(this).data('bs.carousel');
var currentIndex = carouselData.getItemIndex($(e.relatedTarget));

// but that is unnecessary because the current slide is in e.relatedTarget
var currentItem = $(e.relatedTarget);
// currentItem is the current slide's div, use it
});

关于jquery - 在 Bootstrap 轮播的事件幻灯片中查找元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28216596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com