Bootstrap - 以编程方式附加并显示元素的弹出窗口

ilt*_*dev 11 jquery twitter-bootstrap twitter-bootstrap-3 bootstrap-popover

我正在使用Bootstrap v3,我试图在页面加载时以编程方式显示元素旁边的弹出窗口.DOM中没有popover标记.我想在JQuery中创建并显示它.

我试过这个,但它不起作用.

$( document ).ready(function() {
   $('.theElement').popover({
            placement:'right',
            trigger:'manual',
            html:true,
            content:'popover content'
        });
   $('.theElement').popover('show')
});
Run Code Online (Sandbox Code Playgroud)

我在控制台中收到"TypeError:Window.getComputedStyle的参数1不是对象"错误.我假设这是由上述原因造成的.

Dey*_*son 5

试试这个

$( document ).ready(function() {
   $('.theElement').attr('data-placement','right')
   //add all atributes.....

   //and finally show the popover
   $('.theElement').popover('show')
});
Run Code Online (Sandbox Code Playgroud)