繁体   English   中英

Popover Bootstrap-如何使其更清洁

[英]Popover Bootstrap - How to make it cleaner

我试图找出构建弹出框的不同方法,而不必在标记中声明其所有属性。 是否可以将其分组在一个类中,或在.popover()中声明?

例如,是否可以更改

<a href="#" id="example" class="btn btn-primary" rel="popover"
data-content="This is the body of Popover"
data-original-title="Creativity Tuts">pop
</a>

$(function () {
    $('#example').popover();
});

像这样更清洁的东西

<a href="#" id="cleaner" class="btn btn-primary">pop2</a>

$(function () {
    $('cleaner').popover({
        //where I would rather declare rel="popover", 
        //data-content="This is the body of Popover" and so on.
    });
});

这是我的jsfiddle。

先感谢您。

是的,有可能,您在这里:

$(function () {
    $('#cleaner').popover({
        content : "This is the body of popover",
        title : "Creativity Tuts",
    });
});

当然:

$(function () {
  $('#cleaner').attr({
    'rel': 'popover',
    'data-content': 'This is the body of Popover',
    'data-original-title': 'Creativity Tuts'
  });
  $('#cleaner').popover();
});

我认为您必须对文档进行修改

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM