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

标签 jquery twitter-bootstrap carousel

我正在尝试对 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/

相关文章:

html - 如何在特定情况下跳过一些修改过的 CSS 组件而使用原来的 CSS 组件?

flutter - carousel_slider( flutter 包)中的 “items: child”是什么意思?

javascript - Twitter Bootstrap Carousel 跳过问题

javascript - Jquery悬停下拉菜单关闭问题

javascript - Highcharts/Highstocks : Chart disappears when value is 0

javascript - 为 twitter bootstrap 加载掩码插件

html - 垂直居中不起作用,因为行不会达到 100% 高度

javascript - 通过 jquery 或 ajax 加载内容

javascript - 在 Firefox 4 for Android 中禁用文档上的触摸事件

html - 如何让我的图像和 div 位于同一行和高度上?