检索自引导旋转木马中的隐藏值

Retrieving hidden value inside a bootstrap carousel

本文关键字:隐藏 旋转木马 检索      更新时间:2023-09-26

我对这个有点困惑

在bootstrap旋转木马的幻灯片中检索隐藏类型的值最简单的方法是什么?

以幻灯片2中的

为例,我想检索以下指令

 <div class="item" data-slide-number="2">
     <div class="topic-content">
         <input type="hidden" id="hdnInstruction" data-instruction = "Click button to proceed to next topic" />

使用这个var instruction = $("#hdnInstruction").data().instruction;将检索值,因为它是在旋转木马内找到的,但我想检索值…例如,只有一次用户访问了2号幻灯片

您可以使用当前活动状态和轮播事件的组合。

像这样,例如:

$('#myCarousel').bind('slid', function() {
    $('.showText').text($('#myCarousel .item.active img').data('instruction'));
});

假设使用value of a hidden type,您指的是数据属性值,就像您在示例中使用它一样。

工作小提琴