嗨,我必须使用 boostrap 的 popover 或工具提示...我从很多按钮中使用 classname 调用 popover.. 我只想用 javascript 在屏幕中央打开所有按钮 popover。
THX
答案 0 :(得分:0)
我会为所有弹出框添加一个 css 类,以便您可以识别它们并遍历所有元素并显示它们。
这里是一些示例代码:
// Get all elements with 'my-popover-class' class
const popoverCollection = document.getElementsByClassName('my-popover-class');
// Add your options
const popoverOptions = {};
for(let i = 0; i < popoverCollection .length; i++) {
let popover = new bootstrap.Popover(popoverCollection[i], popoverOptions );
popover.show();
}