我找不到完整的文档。例如,popover
效果 ( here ) 将使用 DOM 的 data-origin-title
属性作为其自己的标题,并使用 data-cotent
作为其内容:
$('#somedom').hover (->
$(this).addClass("hover")
$(this).attr("data-original-title","Location")
$(this).attr("data-content":'The popover plugin provides a simple interface for adding popovers to your appli cation. It extends the bootstrap-twipsy.js plugin,
so be sure to grab that file as well when including popovers in your project!')
$(this).popover({})
$(this).popover("show")
),->
$(this).removeClass("hover")
哪里可以学?官方文档没有 data-origin-title
属性。 bootstrap-popover.js
的源代码中都没有。
最佳答案
您需要的一切就在选项表格中。它获取标题的 title
属性,获取内容的 data-content
属性(第三列)。您在 HTML 上看到的 data-original-title
是插件脚本执行后添加的,请忽略它。
这样做的想法是您已经拥有 HTML 上的信息:
<div id="mything" title="My title=" data-content="Some text here">Test popover</div>
所以你的脚本只做这个,你不需要处理事件:
$('#mything').popover()
关于javascript - 你怎么知道如何使用 twitter-bootstrap?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7716073/