Dynamically add a class to Bootstrap's 'popover' container

后端 未结 22 2555
名媛妹妹
名媛妹妹 2020-11-29 18:27

I\'ve thoroughly searched through both StackOverflow and Google, but come up empty. So apologies in advance if this has been asked & resolved already.

NB

22条回答
  •  孤独总比滥情好
    2020-11-29 18:47

    I had the same problem, I liked the answer of @Kate, but changes in the source file can generate so much problems in the future, you probably will forget these little changes when you update your bootstrap's version. So I found another way of doing that:

     $(element).popover({...}).data("popover").tip().addClass("your_class")
    

    As @CorayThan fix it with data("popover")

    The method tip() of popover returns the popover element, and creates when it is not created, therefore you will always get the correct popover element, even if you are at the initialization of popover (This is my case =D ).

提交回复
热议问题