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

后端 未结 22 2514
名媛妹妹
名媛妹妹 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:45

    Its an old post but I'm adding it just as reference. Modifying Shankar Cabus answer, instead of adding the dynamic-class to parent, it will be added in the created .popover div.

    $(function(){
        $('a[rel=popover]')
        .popover({
            placement : 'bottom',
            trigger : 'hover'
        })
        .on("hover", function(){
            $('.popover').addClass($(this).data("class")); //Add class .dynamic-class to 
    }); });

    Hope this helps :)

提交回复
热议问题