首页 新闻 赞助 找找看

Bootstrap popover 为嘛弹出的信息不变?

0
悬赏园豆:10 [已解决问题] 解决于 2017-08-18 10:28

代码:

    <script>
        var txt = '?'

        function abc(a) {
            txt = a;
            return txt;
        }

        $(document).ready(function () {
            hcpopover();

            $("#temp1").click(function () {
                abc('唉唉唉,都是坑?');
                //hcpopover()
            });

            $("#temp2").click(function () {
                abc('还有这种操作?');
                //hcpopover()
            });
        });

        function hcpopover() {
            $("#temp1,#temp2").attr("data-toggle", "popover");
            $('[data-toggle="popover"]').each(function () {
                var element = $(this);
                element.popover({
                    trigger: 'manual',
                    placement: 'bottom', //top, bottom, left or right
                    html: 'true',
                    content: txt,

                }).on("click", function () {
                    var _this = this;
                    $(this).popover("show");
                    $(this).siblings(".popover").on("mouseleave", function () {
                        $(_this).popover('hide');
                    });

                }).on("mouseleave", function () {
                    var _this = this;
                    setTimeout(function () {
                        if (!$(".popover:hover").length) {
                            $(_this).popover("hide")
                        }
                    }, 100);
                });
            });
        }
    </script>

 

 

        <a id="temp1" class="btn btn-lg btn-danger">弹出框1</a>
        <a id="temp2" class="btn btn-lg btn-danger">弹出框2</a>

引用的脚本:

<script src="/js/jquery/jquery-1.7.1.min.js" type="text/javascript"></script>

<script src="/js/bootstrap/bootstrap.min.js" type="text/javascript"></script>

1,弹出信息有默认值,点击按钮后,应该显示不同内容,

结果显示的是默认值,

2,断点测试的时候,应该是我逐步向下编译完后才会出结果,

但是一点击结果就出来了...

Anmen的主页 Anmen | 初学一级 | 园豆:70
提问于:2017-08-17 11:14
< >
分享
最佳答案
0

在popover方法前对提示内容进行修改...

Anmen | 初学一级 |园豆:70 | 2017-08-18 10:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册