【问题标题】:Finding the value of data-attribute inside bootstrap carousel在引导轮播中查找数据属性的值
【发布时间】:2015-08-12 22:44:28
【问题描述】:

如何在引导轮播中找到(检测)数据属性的值。

例如

<div class="item" data-slide-number="2" data-nexttopic="T0024">

                    <div class="topic-content">

我需要检索下一个主题的值

我会想一些类似的东西

var topicValue = $(e.relatedTarget).find("[data-nexttopic]").val();

【问题讨论】:

  • 尝试 attr() 代替 var topicValue = $(e.relatedTarget).attr("data-nexttopic").val();

标签: jquery twitter-bootstrap custom-data-attribute


【解决方案1】:

你可以通过两种方式做到这一点

1) 使用数据属性

var topicValue = $(e.relatedTarget).data("nexttopic");

2) 使用普通属性

var topicValue = $(e.relatedTarget).attr("data-nexttopic");

【讨论】:

    【解决方案2】:

    试试这个,

    var topicValue = $(e.relatedTarget).attr('data-nexttopic');

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 2017-04-08
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-16
      相关资源
      最近更新 更多