如何在运行时在popover的数据内容标签中添加数据?

时间:2023-01-27 13:37:07

I am using Boostrap in MVC application.

我在MVC应用程序中使用Boostrap。

I am trying to add the data to display in popover run time. but its not working...

我试图添加数据以在弹出窗口运行时显示。但它不起作用......

I have this code...

我有这个代码......

<html>
<body>
   <a href="#" id="example" class="btn btn-danger" rel="popover" data-content="" data-original-title="Twitter Bootstrap Popover">hover for popover</a>  
</body>
</html>



 <script>


        $(function () {
            $("#example").popover("Adding data run time here...");
        });



    </script>

3 个解决方案

#1


0  

Use the .attr() function:

使用.attr()函数:

$("#example").attr("data-content", "Adding data run time here...");

#2


0  

I found the answer...

我找到了答案......

<html>
<body>
   <a href="#" id="example" class="btn btn-danger" rel="popover" data-content="" data-original-title="Twitter Bootstrap Popover">hover for popover</a>  
</body>
</html>

<script>

    $(function () {
        $("#example").attr("data-content", getData()).popover();
    });

    function getData()
    {
        return "Here is the runtime data";
    }

</script>

#3


0  

hover for popover

徘徊为popover

$("#example").popover({ placement: 'top', content: 'Add data here', });

#1


0  

Use the .attr() function:

使用.attr()函数:

$("#example").attr("data-content", "Adding data run time here...");

#2


0  

I found the answer...

我找到了答案......

<html>
<body>
   <a href="#" id="example" class="btn btn-danger" rel="popover" data-content="" data-original-title="Twitter Bootstrap Popover">hover for popover</a>  
</body>
</html>

<script>

    $(function () {
        $("#example").attr("data-content", getData()).popover();
    });

    function getData()
    {
        return "Here is the runtime data";
    }

</script>

#3


0  

hover for popover

徘徊为popover

$("#example").popover({ placement: 'top', content: 'Add data here', });