gpt4 book ai didi

javascript - Bootstrap v4 传送带未初始化

转载 作者:行者123 更新时间:2023-11-28 02:30:52 25 4
gpt4 key购买 nike

我正在尝试让 Bootstrap v4 Slider 工作。

它应该在 slider 右侧有文本,并且该文本会随每张幻灯片而变化。

我已经添加了所需的 CSS/JS,但 slider 不会初始化。

Link to JS FIDDLE

我的JS:

<script>
$( document ).ready(function() {
//set here the speed to change the slides in the carousel
$('#features').carousel({});

//Loads the html to each slider. Write in the "div id="slide-content-x" what you want to show in each slide
$('#carousel-text').html($('#slide-content-0').html());


// When the carousel slides, auto update the text
$('#features').on('slid.bs.carousel', function (e) {
var id = $('.item.active').data('slide-number');
$('#carousel-text').html($('#slide-content-'+id).html());
});
});

</script>

最佳答案

看起来您在示例中的标记还不够。

你有一个 .carousel-inner div 容器,里面没有 .carousel-item。这当然只是一张幻灯片。

尝试按照 bootstrap documentation 提供的示例进行操作

将您的 #slide-content-x 容器放入多个 .carousel-inner div 中,并为此删除您的 JS 解决方法。

你不需要任何 JS。它正在 self 初始化。

在这里查看我的工作示例:https://jsfiddle.net/y8h5oqfw/2/

关于javascript - Bootstrap v4 传送带未初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47713528/

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