是否可以为 Twitter Bootstrap 弹出窗口分配一个 id? [英] Is it possible to assign an id to a Twitter Bootstrap popover?
本文介绍了是否可以为 Twitter Bootstrap 弹出窗口分配一个 id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经能够显示 Twitter Bootstrap 弹出框,但有没有办法在创建时为它们分配 id,以便我可以操纵它们?
I've been able to get the Twitter Bootstrap popovers to show but is there a way to assign id's to them on creation so I can manipulate them?
这是我目前的代码:.js
Heres my code so far: .js
$('#test-button').popover({content:'test.', trigger:'click'});
$('#test-button').popover('show');
.html
<a id='test-button' rel='popover'>
推荐答案
有几个选项可以用来获取 popover 元素:
There are a couple of options you could use to get the popover element:
1) 修改 Boostrap Popover 以接受一个options 对象上的 id 属性并将其注入模板(第 102 行)
1) Modify Boostrap Popover to accept an id property on the options object and inject that into the template (line: 102)
2) 使用 id 设置 popover 选项的 html 属性,例如
2) Set the html property on popover options using an id e.g.
$('#test-button').popover({html: true, content: '<div id="test-popover-content">... </div>'})
然后通过
var testPopover = $('#test-popover-content').parent().parent();
这篇关于是否可以为 Twitter Bootstrap 弹出窗口分配一个 id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文