How to update bootstrap popover text?

后端 未结 9 852
长发绾君心
长发绾君心 2020-12-07 20:31

I am using bootstrap-popover to show a message beside an element.

If I want to show different text in the popover after the first time, the text does not change. Re

9条回答
  •  旧巷少年郎
    2020-12-07 20:31

    Old question, but since I notice that the no answer provides the correct way and this is a common question, I'd like to update it.

    Use the $("a#test").popover("destroy");-method. Fiddle here.

    This will destroy the old popover and enable you to connect a new one again the regular way.

    Here's an example where you can click a button to set a new popover on an object that already has a popover attached. See fiddle for more detail.

    $("button.setNewPopoverContent").on("click", function(e) {
        e.preventDefault();
    
        $(".popoverObject").popover("destroy").popover({
            title: "New title"
            content: "New content"
        );
    });
    

提交回复
热议问题