【问题标题】:data-toggle title reset not resetting text数据切换标题重置不重置文本
【发布时间】:2014-05-22 17:48:17
【问题描述】:

我在 div 上设置了一个工具提示,如下所示; (坦率地说,我不确定我为什么要这样做,但我看到一个使用它的 sn-p 并且它以我喜欢的方式工作)

 <div id="termsandconditions" class="col-xs-6" data-toggle="tooltip" title="Agree to the terms to enable the form">
        <a href="#modal-terms" data-toggle="modal" class="register-terms">Terms</a>
        <label class="switch switch-primary" >
            <input type="checkbox" id="register-terms" name="register-terms">
            <span></span>
        </label>
 </div>

更新 这会产生一个样式化的模式工具提示弹出窗口,我想在单击事件时更改其中的文本。 我怀疑我无法更改文本与 data-toggle 属性有关。 使用 prop 或 attr 会更改工具提示,但不会更改从 data-toggle 设置的模态工具提示弹出窗口中的标题文本。

下面其实是添加了一个tooltip,但是不要改变原来弹出的tooltip里面的文字

  $("#termsandconditions").dialog("option", "title", "De-selecting terms will disable the form");
  $('#termsandconditions').prop('title', 'De-selecting terms will disable the form');

【问题讨论】:

  • 是的,它在你的小提琴中工作,它应该,但它在我的页面上不起作用。一定有什么东西覆盖了它
  • 您是否使用任何插件来呈现您的工具提示?
  • @dinotom,问题一定出在其他地方。您需要提供更多信息。截至目前,问题不是再现

标签: javascript jquery


【解决方案1】:
$('#termsandconditions').attr('data-original-title', 'De-selecting terms will disable the form');

【讨论】:

  • @khriskooper...干得好。你是怎么找到这个的?有没有我可以细读的文档?
  • 看起来你正在使用引导程序,它有自己独特的呈现工具提示的方式,结果会弄乱你的 HTML。我总是发现查看到底发生了什么的最佳方法是在浏览器中搜索和调试 HTML。我在 Bootstrap 网站上找不到任何文档,但是有几个在线使用它的示例。只需在 Google 中搜索“在引导程序中动态更改工具提示标题”即可。
【解决方案2】:
$('#termsandconditions').attr('title', 'De-selecting terms will disable the form');

【讨论】:

  • 使用 attr 与 prop 示例相同,prop 现在是 1.6 或更高版本的标准,但也不起作用。它会在一个正常的标题属性上,但我怀疑数据切换是什么让它无法工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-20
  • 1970-01-01
  • 2019-05-30
相关资源
最近更新 更多