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

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

    Sorry, but did not quite understand your question ... But what you want is to add a parent div? Take it easy ... See if this is what you want:

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

    Demo: http://jsfiddle.net/PRQfJ/

提交回复
热议问题